From bfd342fd8a77898af2d726066937b1454818688b Mon Sep 17 00:00:00 2001 From: "rmacnak@google.com" Date: Mon, 14 Jul 2014 18:00:04 +0000 Subject: [PATCH] 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 --- runtime/lib/mirrors.cc | 70 ++++-------- runtime/lib/mirrors_patch.dart | 11 -- .../dart/mirrored_compilation_error_test.dart | 103 ------------------ runtime/tests/vm/vm.status | 6 - runtime/vm/exceptions.cc | 4 - runtime/vm/exceptions.h | 1 - runtime/vm/symbols.h | 1 - tests/lib/mirrors/removed_api_test.dart | 2 +- tests/standalone/issue14236_test.dart | Bin 10110 -> 10102 bytes 9 files changed, 23 insertions(+), 175 deletions(-) delete mode 100644 runtime/tests/vm/dart/mirrored_compilation_error_test.dart diff --git a/runtime/lib/mirrors.cc b/runtime/lib/mirrors.cc index 5eb63fdcaf6..463b3de856b 100644 --- a/runtime/lib/mirrors.cc +++ b/runtime/lib/mirrors.cc @@ -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(); diff --git a/runtime/lib/mirrors_patch.dart b/runtime/lib/mirrors_patch.dart index b3eaf9a1853..962a1c73abf 100644 --- a/runtime/lib/mirrors_patch.dart +++ b/runtime/lib/mirrors_patch.dart @@ -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>"; - } -} diff --git a/runtime/tests/vm/dart/mirrored_compilation_error_test.dart b/runtime/tests/vm/dart/mirrored_compilation_error_test.dart deleted file mode 100644 index 7be51d305fd..00000000000 --- a/runtime/tests/vm/dart/mirrored_compilation_error_test.dart +++ /dev/null @@ -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 { - G(); - factory G.swap() = G; /// 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()).type; - raises(() => cm.newInstance(#swap, [])); - } -} diff --git a/runtime/tests/vm/vm.status b/runtime/tests/vm/vm.status index 451e4c0a7e3..c2a18b3a94c 100644 --- a/runtime/tests/vm/vm.status +++ b/runtime/tests/vm/vm.status @@ -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 diff --git a/runtime/vm/exceptions.cc b/runtime/vm/exceptions.cc index bc267ef7e17..c8808dde56d 100644 --- a/runtime/vm/exceptions.cc +++ b/runtime/vm/exceptions.cc @@ -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, diff --git a/runtime/vm/exceptions.h b/runtime/vm/exceptions.h index 4b3330cc36b..5e87e3ba281 100644 --- a/runtime/vm/exceptions.h +++ b/runtime/vm/exceptions.h @@ -65,7 +65,6 @@ class Exceptions : AllStatic { kType, kFallThrough, kAbstractClassInstantiation, - kMirroredCompilationError, }; static void ThrowByType(ExceptionType type, const Array& arguments); diff --git a/runtime/vm/symbols.h b/runtime/vm/symbols.h index ed1cdd617d9..727b30956fd 100644 --- a/runtime/vm/symbols.h +++ b/runtime/vm/symbols.h @@ -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") \ diff --git a/tests/lib/mirrors/removed_api_test.dart b/tests/lib/mirrors/removed_api_test.dart index 800d4e43f0c..6f5e6bc49d4 100644 --- a/tests/lib/mirrors/removed_api_test.dart +++ b/tests/lib/mirrors/removed_api_test.dart @@ -33,5 +33,5 @@ main() { expectThrowsNSM(() => MirroredError); expectThrowsNSM(() => MirrorException); expectThrowsNSM(() => MirroredUncaughtExceptionError); - // Don't ask about MirroredCompilationError. + expectThrowsNSM(() => MirroredCompilationError); } diff --git a/tests/standalone/issue14236_test.dart b/tests/standalone/issue14236_test.dart index bba1a24b671a64d4247588d418df229196a88aec..96de13730f576e6cb115099ca68633d42b6baf7e 100644 GIT binary patch delta 521 zcmez8_sx&>>(@JXiYBsJ8|WN#i8B{CmX?{5YNfBQpPQPJnW$fso0y!Jn5`e2pOcvq zT#{Ils-KcrRHB=nSu#1AQCDcM<`L#Y3|9^~SQr_Zniv>bnoQhm!u0aT#FsLRY?Ij- z70EF+TJXTv#$UgiS`Ym0`qTKgsq;YF8H@h+^GqEUcu0Jw)qI}TgeJs+9 zikok-XfVneZr;0hZ{U&ggA7OZx*zdB>UtE&Jha#K82>>YhRO15I*dG~$#3_lpR zFmBmgEaA+;9J)Sq@=h5)M%&38vgXW=YdI%7$+`n+$H_giQp}t{{z_RDX3O=KlP}1M zGY78qo%~AHo{@91mYfwM$K+HwTSl(Qi{-2t4JY51^I_zktRsJ!(QuMNIV11p3Wan= zkS8ZUQp{o$-R!F*$po|}T_r^5QuJB-v;0R^?%k7mZYIO00|zcmKC2SM$TwL*)d#2~ zSJheQQan(J=6RrR`42Mdp5Mx$IQfvOF3_3}s);;6-)-Ls1nFn=&rWt^5t&@5<_&h+ Kezm(@JXswT2po0uH*Vn|j!oR*oBYNfBQUs_zGpOc@Qn4_PbpP!zSs-Kac zo2s9kpOUDbkyxA&Uy_)VlRB}$jMK!#$jHpl)WmS&dXxGW-wzx-a6o{4-+=?3N0<-s zoM1B6D?eV6T3q6LWUBz{sY3_%@85smipT@k-Lbm^kCY!gvUTs?t$Ra{^a?}*)w7V} z2>q1Aq7r?O9mNx?l_obZ>P=qHC_ecpV=1%jX4%cQOv+4*vXc{83K(TKUt-Z}F@RM`>5mpc_I9Wl+hf#NPuFyJ0=E!xCo8?4! zSQsTIYfBjO>aNvYD|%`w!;jj{wVO9*OE|MI2d)pCyivxF(Q=ZkIkW9r*2z|~?h3YR zZPz-U0jhI70}P2H5sc<32h_RT&v*jGezO7E^}O#o=O Rms%Dx$Zgxz_A*(n1pv0#*((45