Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Unified Diff: runtime/vm/code_generator_ia32.cc

Issue 9515011: Add support for malformed types and postpone some related errors from compile (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | runtime/vm/code_generator_x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_generator_ia32.cc
===================================================================
--- runtime/vm/code_generator_ia32.cc (revision 4731)
+++ runtime/vm/code_generator_ia32.cc (working copy)
@@ -810,8 +810,7 @@
void CodeGenerator::VisitCloneContextNode(CloneContextNode *node) {
- const Context& result = Context::ZoneHandle();
- __ PushObject(result);
+ __ PushObject(Object::ZoneHandle()); // Make room for the result.
__ pushl(CTX);
GenerateCallRuntime(node->id(),
node->token_index(), kCloneContextRuntimeEntry);
@@ -1311,7 +1310,7 @@
intptr_t token_index,
const AbstractType& type,
bool negate_result) {
- ASSERT(type.IsFinalized());
+ ASSERT(type.IsFinalized() && !type.IsMalformed());
const Bool& bool_true = Bool::ZoneHandle(Bool::True());
const Bool& bool_false = Bool::ZoneHandle(Bool::False());
@@ -1419,8 +1418,7 @@
}
}
}
- const Object& result = Object::ZoneHandle();
- __ PushObject(result); // Make room for the result of the runtime call.
+ __ PushObject(Object::ZoneHandle()); // Make room for the result.
__ pushl(EAX); // Push the instance.
__ PushObject(type); // Push the type.
if (!type.IsInstantiated()) {
@@ -1473,6 +1471,23 @@
ASSERT(!dst_type.IsNull());
ASSERT(dst_type.IsFinalized());
+ // Generate throw new TypeError() if the type is malformed.
+ if (dst_type.IsMalformed()) {
+ const Error& error = Error::Handle(dst_type.malformed_error());
+ const String& error_message = String::ZoneHandle(
+ String::NewSymbol(error.ToErrorCString()));
+ __ PushObject(Object::ZoneHandle()); // Make room for the result.
+ const Immediate location =
+ Immediate(reinterpret_cast<int32_t>(Smi::New(token_index)));
+ __ pushl(location); // Push the source location.
+ __ pushl(EAX); // Push the source object.
+ __ PushObject(error_message);
+ GenerateCallRuntime(node_id, token_index, kMalformedTypeErrorRuntimeEntry);
+ // We should never return here.
+ __ int3();
+ return;
+ }
+
// Any expression is assignable to the Dynamic type and to the Object type.
// Skip the test.
if (dst_type.IsDynamicType() || dst_type.IsObjectType()) {
@@ -1594,8 +1609,7 @@
}
}
__ Bind(&runtime_call);
- const Object& result = Object::ZoneHandle();
- __ PushObject(result); // Make room for the result of the runtime call.
+ __ PushObject(Object::ZoneHandle()); // Make room for the result.
const Immediate location =
Immediate(reinterpret_cast<int32_t>(Smi::New(token_index)));
__ pushl(location); // Push the source location.
@@ -1661,16 +1675,13 @@
__ j(EQUAL, &done, Assembler::kNearJump);
__ Bind(&runtime_call);
- const Object& result = Object::ZoneHandle();
- __ PushObject(result); // Make room for the result of the runtime call.
const Immediate location =
Immediate(reinterpret_cast<int32_t>(Smi::New(token_index)));
__ pushl(location); // Push the source location.
__ pushl(EAX); // Push the source object.
GenerateCallRuntime(node_id, token_index, kConditionTypeErrorRuntimeEntry);
- // Pop the parameters supplied to the runtime entry. The result of the
- // type check runtime call is the checked value.
- __ addl(ESP, Immediate(3 * kWordSize));
+ // We should never return here.
+ __ int3();
__ Bind(&done);
}
@@ -2196,7 +2207,8 @@
// TODO(regis): Temporary type should be allocated in new gen heap.
Type& type = Type::Handle(
Type::New(instantiator_class, type_arguments, token_index));
- type ^= ClassFinalizer::FinalizeType(instantiator_class, type);
+ type ^= ClassFinalizer::FinalizeType(
+ instantiator_class, type, ClassFinalizer::kFinalizeWellFormed);
type_arguments = type.arguments();
__ PushObject(type_arguments);
} else {
@@ -2279,8 +2291,7 @@
if (node->constructor().IsFactory()) {
// A runtime call to instantiate the type arguments is required before
// calling the factory.
- const Object& result = Object::ZoneHandle();
- __ PushObject(result); // Make room for the result of the runtime call.
+ __ PushObject(Object::ZoneHandle()); // Make room for the result.
__ PushObject(node->type_arguments());
__ pushl(EAX); // Push instantiator type arguments.
GenerateCallRuntime(node->id(),
@@ -2614,17 +2625,12 @@
void CodeGenerator::VisitThrowNode(ThrowNode* node) {
- const Object& result = Object::ZoneHandle();
node->exception()->Visit(this);
- __ popl(EAX); // Exception object is now in EAX.
+ // Exception object is on TOS.
if (node->stacktrace() != NULL) {
- __ PushObject(result); // Make room for the result of the runtime call.
- __ pushl(EAX); // Push the exception object.
node->stacktrace()->Visit(this);
GenerateCallRuntime(node->id(), node->token_index(), kReThrowRuntimeEntry);
} else {
- __ PushObject(result); // Make room for the result of the runtime call.
- __ pushl(EAX); // Push the exception object.
GenerateCallRuntime(node->id(), node->token_index(), kThrowRuntimeEntry);
}
// We should never return here.
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | runtime/vm/code_generator_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698