Remove MirroredCompilationError from the VM.
Regenerate snapshot test due to removed symbol. BUG=http://dartbug.com/16562 R=regis@google.com Review URL: https://codereview.chromium.org//389573007 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38202 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
+22
-48
@@ -16,10 +16,6 @@
|
||||
|
||||
namespace dart {
|
||||
|
||||
DEFINE_FLAG(bool, use_mirrored_compilation_error, false,
|
||||
"Wrap compilation errors that occur during reflective access in a "
|
||||
"MirroredCompilationError, rather than suspending the isolate.");
|
||||
|
||||
static RawInstance* CreateMirror(const String& mirror_class_name,
|
||||
const Array& constructor_arguments) {
|
||||
const Library& mirrors_lib = Library::Handle(Library::MirrorsLibrary());
|
||||
@@ -35,28 +31,6 @@ static RawInstance* CreateMirror(const String& mirror_class_name,
|
||||
}
|
||||
|
||||
|
||||
static void ThrowMirroredCompilationError(const String& message) {
|
||||
Array& args = Array::Handle(Array::New(1));
|
||||
args.SetAt(0, message);
|
||||
|
||||
Exceptions::ThrowByType(Exceptions::kMirroredCompilationError, args);
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
|
||||
static void ThrowInvokeError(const Error& error) {
|
||||
if (FLAG_use_mirrored_compilation_error && error.IsLanguageError()) {
|
||||
// A compilation error that was delayed by lazy compilation.
|
||||
const LanguageError& compilation_error = LanguageError::Cast(error);
|
||||
String& message = String::Handle(compilation_error.FormatMessage());
|
||||
ThrowMirroredCompilationError(message);
|
||||
UNREACHABLE();
|
||||
}
|
||||
Exceptions::PropagateError(error);
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
|
||||
// Conventions:
|
||||
// * For throwing a NSM in a class klass we use its runtime type as receiver,
|
||||
// i.e., klass.RareType().
|
||||
@@ -102,14 +76,14 @@ static void EnsureConstructorsAreCompiled(const Function& func) {
|
||||
const Error& error = Error::Handle(
|
||||
isolate, cls.EnsureIsFinalized(Isolate::Current()));
|
||||
if (!error.IsNull()) {
|
||||
ThrowInvokeError(error);
|
||||
Exceptions::PropagateError(error);
|
||||
UNREACHABLE();
|
||||
}
|
||||
if (!func.HasCode()) {
|
||||
const Error& error = Error::Handle(
|
||||
isolate, Compiler::CompileFunction(isolate, func));
|
||||
if (!error.IsNull()) {
|
||||
ThrowInvokeError(error);
|
||||
Exceptions::PropagateError(error);
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
@@ -158,7 +132,7 @@ static RawInstance* CreateParameterMirrorList(const Function& func,
|
||||
const Object& result =
|
||||
Object::Handle(Parser::ParseFunctionParameters(func));
|
||||
if (result.IsError()) {
|
||||
ThrowInvokeError(Error::Cast(result));
|
||||
Exceptions::PropagateError(Error::Cast(result));
|
||||
UNREACHABLE();
|
||||
}
|
||||
param_descriptor ^= result.raw();
|
||||
@@ -350,7 +324,7 @@ static RawInstance* CreateClassMirror(const Class& cls,
|
||||
|
||||
const Error& error = Error::Handle(cls.EnsureIsFinalized(Isolate::Current()));
|
||||
if (!error.IsNull()) {
|
||||
ThrowInvokeError(error);
|
||||
Exceptions::PropagateError(error);
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
@@ -434,7 +408,7 @@ static RawInstance* CreateLibraryDependencyMirror(const Instance& importer,
|
||||
|
||||
Object& metadata = Object::Handle(ns.GetMetadata());
|
||||
if (metadata.IsError()) {
|
||||
ThrowInvokeError(Error::Cast(metadata));
|
||||
Exceptions::PropagateError(Error::Cast(metadata));
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
@@ -590,7 +564,7 @@ static RawInstance* CreateMirrorSystem() {
|
||||
|
||||
static RawInstance* ReturnResult(const Object& result) {
|
||||
if (result.IsError()) {
|
||||
ThrowInvokeError(Error::Cast(result));
|
||||
Exceptions::PropagateError(Error::Cast(result));
|
||||
UNREACHABLE();
|
||||
}
|
||||
if (result.IsInstance()) {
|
||||
@@ -784,7 +758,7 @@ static RawAbstractType* InstantiateType(const AbstractType& type,
|
||||
AbstractType& result =
|
||||
AbstractType::Handle(type.InstantiateFrom(type_args, &bound_error));
|
||||
if (!bound_error.IsNull()) {
|
||||
ThrowInvokeError(bound_error);
|
||||
Exceptions::PropagateError(bound_error);
|
||||
UNREACHABLE();
|
||||
}
|
||||
ASSERT(result.IsFinalized());
|
||||
@@ -873,7 +847,7 @@ DEFINE_NATIVE_ENTRY(DeclarationMirror_metadata, 1) {
|
||||
|
||||
const Object& metadata = Object::Handle(library.GetMetadata(decl));
|
||||
if (metadata.IsError()) {
|
||||
ThrowInvokeError(Error::Cast(metadata));
|
||||
Exceptions::PropagateError(Error::Cast(metadata));
|
||||
}
|
||||
return metadata.raw();
|
||||
}
|
||||
@@ -962,7 +936,7 @@ DEFINE_NATIVE_ENTRY(ClassMirror_interfaces, 1) {
|
||||
const Class& cls = Class::Handle(type.type_class());
|
||||
const Error& error = Error::Handle(cls.EnsureIsFinalized(isolate));
|
||||
if (!error.IsNull()) {
|
||||
ThrowInvokeError(error);
|
||||
Exceptions::PropagateError(error);
|
||||
}
|
||||
|
||||
return cls.interfaces();
|
||||
@@ -979,7 +953,7 @@ DEFINE_NATIVE_ENTRY(ClassMirror_interfaces_instantiated, 1) {
|
||||
const Class& cls = Class::Handle(type.type_class());
|
||||
const Error& error = Error::Handle(cls.EnsureIsFinalized(isolate));
|
||||
if (!error.IsNull()) {
|
||||
ThrowInvokeError(error);
|
||||
Exceptions::PropagateError(error);
|
||||
}
|
||||
|
||||
Array& interfaces = Array::Handle(cls.interfaces());
|
||||
@@ -1041,7 +1015,7 @@ DEFINE_NATIVE_ENTRY(ClassMirror_members, 2) {
|
||||
|
||||
const Error& error = Error::Handle(klass.EnsureIsFinalized(isolate));
|
||||
if (!error.IsNull()) {
|
||||
ThrowInvokeError(error);
|
||||
Exceptions::PropagateError(error);
|
||||
}
|
||||
|
||||
const Array& fields = Array::Handle(klass.fields());
|
||||
@@ -1088,7 +1062,7 @@ DEFINE_NATIVE_ENTRY(ClassMirror_constructors, 2) {
|
||||
|
||||
const Error& error = Error::Handle(klass.EnsureIsFinalized(isolate));
|
||||
if (!error.IsNull()) {
|
||||
ThrowInvokeError(error);
|
||||
Exceptions::PropagateError(error);
|
||||
}
|
||||
|
||||
const Array& functions = Array::Handle(klass.functions());
|
||||
@@ -1310,7 +1284,7 @@ DEFINE_NATIVE_ENTRY(InstanceMirror_invoke, 5) {
|
||||
const Object& call_result =
|
||||
Object::Handle(DartEntry::InvokeClosure(args, args_descriptor));
|
||||
if (call_result.IsError()) {
|
||||
ThrowInvokeError(Error::Cast(call_result));
|
||||
Exceptions::PropagateError(Error::Cast(call_result));
|
||||
UNREACHABLE();
|
||||
}
|
||||
return call_result.raw();
|
||||
@@ -1412,7 +1386,7 @@ DEFINE_NATIVE_ENTRY(ClassMirror_invoke, 5) {
|
||||
const Object& getter_result = Object::Handle(
|
||||
DartEntry::InvokeFunction(function, Object::empty_array()));
|
||||
if (getter_result.IsError()) {
|
||||
ThrowInvokeError(Error::Cast(getter_result));
|
||||
Exceptions::PropagateError(Error::Cast(getter_result));
|
||||
UNREACHABLE();
|
||||
}
|
||||
// Make room for the closure (receiver) in the argument list.
|
||||
@@ -1430,7 +1404,7 @@ DEFINE_NATIVE_ENTRY(ClassMirror_invoke, 5) {
|
||||
const Object& call_result = Object::Handle(
|
||||
DartEntry::InvokeClosure(call_args, call_args_descriptor_array));
|
||||
if (call_result.IsError()) {
|
||||
ThrowInvokeError(Error::Cast(call_result));
|
||||
Exceptions::PropagateError(Error::Cast(call_result));
|
||||
UNREACHABLE();
|
||||
}
|
||||
return call_result.raw();
|
||||
@@ -1457,7 +1431,7 @@ DEFINE_NATIVE_ENTRY(ClassMirror_invoke, 5) {
|
||||
Object& result = Object::Handle(
|
||||
DartEntry::InvokeFunction(function, args, args_descriptor_array));
|
||||
if (result.IsError()) {
|
||||
ThrowInvokeError(Error::Cast(result));
|
||||
Exceptions::PropagateError(Error::Cast(result));
|
||||
UNREACHABLE();
|
||||
}
|
||||
return result.raw();
|
||||
@@ -1511,7 +1485,7 @@ DEFINE_NATIVE_ENTRY(ClassMirror_invokeSetter, 4) {
|
||||
Object& result = Object::Handle(
|
||||
DartEntry::InvokeFunction(setter, args));
|
||||
if (result.IsError()) {
|
||||
ThrowInvokeError(Error::Cast(result));
|
||||
Exceptions::PropagateError(Error::Cast(result));
|
||||
UNREACHABLE();
|
||||
}
|
||||
return result.raw();
|
||||
@@ -1603,7 +1577,7 @@ DEFINE_NATIVE_ENTRY(ClassMirror_invokeConstructor, 5) {
|
||||
redirect_type ^= redirect_type.InstantiateFrom(type_arguments,
|
||||
&bound_error);
|
||||
if (!bound_error.IsNull()) {
|
||||
ThrowInvokeError(bound_error);
|
||||
Exceptions::PropagateError(bound_error);
|
||||
UNREACHABLE();
|
||||
}
|
||||
redirect_type ^= redirect_type.Canonicalize();
|
||||
@@ -1674,7 +1648,7 @@ DEFINE_NATIVE_ENTRY(ClassMirror_invokeConstructor, 5) {
|
||||
args,
|
||||
args_descriptor_array));
|
||||
if (result.IsError()) {
|
||||
ThrowInvokeError(Error::Cast(result));
|
||||
Exceptions::PropagateError(Error::Cast(result));
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
@@ -1723,7 +1697,7 @@ DEFINE_NATIVE_ENTRY(LibraryMirror_invoke, 5) {
|
||||
const Object& call_result = Object::Handle(
|
||||
DartEntry::InvokeClosure(call_args, call_args_descriptor_array));
|
||||
if (call_result.IsError()) {
|
||||
ThrowInvokeError(Error::Cast(call_result));
|
||||
Exceptions::PropagateError(Error::Cast(call_result));
|
||||
UNREACHABLE();
|
||||
}
|
||||
return call_result.raw();
|
||||
@@ -1749,7 +1723,7 @@ DEFINE_NATIVE_ENTRY(LibraryMirror_invoke, 5) {
|
||||
const Object& result = Object::Handle(
|
||||
DartEntry::InvokeFunction(function, args, args_descriptor_array));
|
||||
if (result.IsError()) {
|
||||
ThrowInvokeError(Error::Cast(result));
|
||||
Exceptions::PropagateError(Error::Cast(result));
|
||||
UNREACHABLE();
|
||||
}
|
||||
return result.raw();
|
||||
@@ -1806,7 +1780,7 @@ DEFINE_NATIVE_ENTRY(LibraryMirror_invokeSetter, 4) {
|
||||
const Object& result = Object::Handle(
|
||||
DartEntry::InvokeFunction(setter, args));
|
||||
if (result.IsError()) {
|
||||
ThrowInvokeError(Error::Cast(result));
|
||||
Exceptions::PropagateError(Error::Cast(result));
|
||||
UNREACHABLE();
|
||||
}
|
||||
return result.raw();
|
||||
|
||||
@@ -101,14 +101,3 @@ patch class MirrorSystem {
|
||||
static _mangleName(String name, _MirrorReference lib)
|
||||
native "Mirrors_mangleName";
|
||||
}
|
||||
|
||||
// TODO(rmacnak): Eliminate this class.
|
||||
class MirroredCompilationError {
|
||||
final String message;
|
||||
|
||||
MirroredCompilationError(this.message);
|
||||
|
||||
String toString() {
|
||||
return "Compile-time error during mirrored execution: <$message>";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// VMOptions=--use_mirrored_compilation_error=true
|
||||
|
||||
@notDefined
|
||||
library mirrored_compilation_error_test;
|
||||
|
||||
import 'dart:mirrors';
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
@notDefined
|
||||
class Class<@notDefined T> {
|
||||
@notDefined
|
||||
var field;
|
||||
|
||||
@notDefined
|
||||
method(@notDefined param) {}
|
||||
}
|
||||
|
||||
class Class2 {
|
||||
method() { +++; }
|
||||
get getter { +++; }
|
||||
set setter(x) { +++; }
|
||||
|
||||
static staticFunction() { +++; }
|
||||
static get staticGetter { +++; }
|
||||
static set staticSetter(x) { +++; }
|
||||
|
||||
Class2() {}
|
||||
Class2.constructor() { +++; }
|
||||
}
|
||||
|
||||
toplevelFunction() { +++; }
|
||||
get toplevelGetter { +++; }
|
||||
set toplevelSetter(x) { +++; }
|
||||
|
||||
|
||||
class G<A extends int, B extends String> {
|
||||
G();
|
||||
factory G.swap() = G<B,A>; /// static type warning
|
||||
}
|
||||
|
||||
raises(closure) {
|
||||
Expect.throws(closure,
|
||||
(e) => e is MirroredCompilationError,
|
||||
'Expected a deferred compilation error');
|
||||
}
|
||||
|
||||
bool get inCheckedMode {
|
||||
try {
|
||||
var i = 1;
|
||||
String s = i;
|
||||
return false;
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
// Metadata.
|
||||
|
||||
raises(() => reflectClass(Class).metadata);
|
||||
raises(() => reflectClass(Class).typeVariables.single.metadata);
|
||||
raises(() => reflectClass(Class).declarations[#field].metadata);
|
||||
raises(() => reflectClass(Class).declarations[#method].metadata);
|
||||
raises(() => reflectClass(Class).declarations[#method].parameters.single.metadata);
|
||||
raises(() => reflectClass(Class).owner.metadata);
|
||||
|
||||
|
||||
// Invocation.
|
||||
|
||||
InstanceMirror im = reflect(new Class2());
|
||||
raises(() => im.invoke(#method, []));
|
||||
raises(() => im.getField(#getter));
|
||||
raises(() => im.setField(#setter, 'some value'));
|
||||
// The implementation is within its right to defer the compilation even
|
||||
// further here, so we apply the tear-off to force compilation.
|
||||
raises(() => im.getField(#method).apply([]));
|
||||
|
||||
ClassMirror cm = reflectClass(Class2);
|
||||
raises(() => cm.invoke(#staticFunction, []));
|
||||
raises(() => cm.getField(#staticGetter));
|
||||
raises(() => cm.setField(#staticSetter, 'some value'));
|
||||
raises(() => cm.getField(#staticFunction).apply([]));
|
||||
raises(() => cm.newInstance(#constructor, []));
|
||||
|
||||
LibraryMirror lm = reflectClass(Class2).owner;
|
||||
raises(() => lm.invoke(#toplevelFunction, []));
|
||||
raises(() => lm.getField(#toplevelGetter));
|
||||
raises(() => lm.setField(#toplevelSetter, 'some value'));
|
||||
raises(() => lm.getField(#toplevelFunction).apply([]));
|
||||
|
||||
|
||||
// Bounds violation.
|
||||
|
||||
if (inCheckedMode) {
|
||||
ClassMirror cm = reflect(new G<int, String>()).type;
|
||||
raises(() => cm.newInstance(#swap, []));
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,6 @@ cc/Coverage_MainWithClass: Skip # Dart bug 16250
|
||||
cc/Service_ClassesCoverage: Skip # Dart bug 16250
|
||||
|
||||
[ $compiler == dart2js ]
|
||||
dart/mirrored_compilation_error_test: Skip # VM-specific flag
|
||||
dart/redirection_type_shuffling_test: Skip # Depends on lazy enforcement of type bounds
|
||||
dart/byte_array_test: Skip # compilers not aware of byte arrays
|
||||
dart/byte_array_optimized_test: Skip # compilers not aware of byte arrays
|
||||
@@ -81,13 +80,8 @@ cc/StaticNonNullSumCallCodegen: Crash, Pass # dartbug.com/17440
|
||||
cc/JSON_JSONStream_Options: Crash # Issue 19328
|
||||
cc/FindCodeObject: Skip # Takes more than 8 minutes. dartbug.com/17440.
|
||||
|
||||
[ $compiler == none && ($runtime == drt || $runtime == dartium || $runtime == ContentShellOnAndroid) ]
|
||||
dart/mirrored_compilation_error_test: Skip # Can't pass needed VM flag
|
||||
|
||||
[ $compiler == dartanalyzer || $compiler == dart2analyzer ]
|
||||
dart/optimized_stacktrace_test: StaticWarning
|
||||
|
||||
dart/mirrored_compilation_error_test: CompileTimeError, OK # This test intentionally includes invalid method bodies.
|
||||
|
||||
[ $compiler == none && $runtime == ContentShellOnAndroid ]
|
||||
dart/byte_array_test: RuntimeError # Issue 17612
|
||||
|
||||
@@ -747,10 +747,6 @@ RawObject* Exceptions::Create(ExceptionType type, const Array& arguments) {
|
||||
class_name = &Symbols::AbstractClassInstantiationError();
|
||||
constructor_name = &Symbols::DotCreate();
|
||||
break;
|
||||
case kMirroredCompilationError:
|
||||
library = Library::MirrorsLibrary();
|
||||
class_name = &Symbols::MirroredCompilationError();
|
||||
break;
|
||||
}
|
||||
|
||||
return DartLibraryCalls::InstanceCreate(library,
|
||||
|
||||
@@ -65,7 +65,6 @@ class Exceptions : AllStatic {
|
||||
kType,
|
||||
kFallThrough,
|
||||
kAbstractClassInstantiation,
|
||||
kMirroredCompilationError,
|
||||
};
|
||||
|
||||
static void ThrowByType(ExceptionType type, const Array& arguments);
|
||||
|
||||
@@ -256,7 +256,6 @@ class ObjectPointerVisitor;
|
||||
V(IsolateUnhandledException, "_IsolateUnhandledException") \
|
||||
V(JavascriptIntegerOverflowError, "_JavascriptIntegerOverflowError") \
|
||||
V(JavascriptCompatibilityError, "_JavascriptCompatibilityError") \
|
||||
V(MirroredCompilationError, "MirroredCompilationError") \
|
||||
V(_setupFullStackTrace, "_setupFullStackTrace") \
|
||||
V(BooleanExpression, "boolean expression") \
|
||||
V(Malformed, "malformed") \
|
||||
|
||||
@@ -33,5 +33,5 @@ main() {
|
||||
expectThrowsNSM(() => MirroredError);
|
||||
expectThrowsNSM(() => MirrorException);
|
||||
expectThrowsNSM(() => MirroredUncaughtExceptionError);
|
||||
// Don't ask about MirroredCompilationError.
|
||||
expectThrowsNSM(() => MirroredCompilationError);
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user