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

Unified Diff: runtime/vm/flow_graph_compiler_x64.cc

Issue 10280007: Check upper bounds of type arguments when allocating objects of a generic type (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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
Index: runtime/vm/flow_graph_compiler_x64.cc
===================================================================
--- runtime/vm/flow_graph_compiler_x64.cc (revision 7209)
+++ runtime/vm/flow_graph_compiler_x64.cc (working copy)
@@ -318,9 +318,7 @@
const String& error_message = String::ZoneHandle(
String::NewSymbol(error.ToErrorCString()));
__ PushObject(Object::ZoneHandle()); // Make room for the result.
- const Immediate location =
- Immediate(reinterpret_cast<int64_t>(Smi::New(token_index)));
- __ pushq(location); // Push the source location.
+ __ pushq(Immediate(Smi::RawValue(token_index))); // Source location.
__ pushq(RAX); // Push the source object.
__ PushObject(dst_name); // Push the name of the destination.
__ PushObject(error_message);
@@ -340,12 +338,8 @@
__ Bind(&runtime_call);
__ PushObject(Object::ZoneHandle()); // Make room for the result.
- const Immediate location =
- Immediate(reinterpret_cast<int64_t>(Smi::New(token_index)));
- const Immediate cid_as_smi =
- Immediate(reinterpret_cast<int64_t>(Smi::New(cid)));
- __ pushq(location); // Push the source location.
- __ pushq(cid_as_smi); // node-id.
+ __ pushq(Immediate(Smi::RawValue(token_index))); // Source location.
+ __ pushq(Immediate(Smi::RawValue(cid))); // Computation id.
__ pushq(RAX); // Push the source object.
__ PushObject(dst_type); // Push the type of the destination.
if (!dst_type.IsInstantiated()) {
@@ -421,9 +415,7 @@
__ CompareObject(RAX, Bool::ZoneHandle(Bool::False()));
__ j(EQUAL, &done, Assembler::kNearJump);
- const Immediate location =
- Immediate(reinterpret_cast<int64_t>(Smi::New(comp->token_index())));
- __ pushq(location); // Push the source location.
+ __ pushq(Immediate(Smi::RawValue(comp->token_index()))); // Source location.
__ pushq(RAX); // Push the source object.
GenerateCallRuntime(comp->cid(),
comp->token_index(),
@@ -842,12 +834,8 @@
// Generate runtime call.
__ PushObject(Object::ZoneHandle()); // Make room for the result.
- const Immediate location =
- Immediate(reinterpret_cast<int64_t>(Smi::New(token_index)));
- const Immediate cid_as_smi =
- Immediate(reinterpret_cast<int64_t>(Smi::New(cid)));
- __ pushq(location); // Push the source location.
- __ pushq(cid_as_smi);
+ __ pushq(Immediate(Smi::RawValue(token_index))); // Source location.
+ __ pushq(Immediate(Smi::RawValue(cid))); // Computation id.
__ pushq(RAX); // Push the instance.
__ PushObject(type); // Push the type.
if (!type.IsInstantiated()) {
@@ -906,6 +894,30 @@
}
+void FlowGraphCompiler::VisitAllocateObjectWithBoundsCheck(
+ AllocateObjectWithBoundsCheckComp* comp) {
+ const Class& cls = Class::ZoneHandle(comp->constructor().owner());
+ __ popq(RCX); // Pop instantiator type arguments.
+ __ popq(RAX); // Pop type arguments.
+
+ // Push the result place holder initialized to NULL.
+ __ PushObject(Object::ZoneHandle());
+ __ pushq(Immediate(Smi::RawValue(comp->token_index())));
+ __ PushObject(cls);
+ __ pushq(RAX); // Push type arguments.
+ __ pushq(RCX); // Push instantiator type arguments.
+ GenerateCallRuntime(comp->cid(),
+ comp->token_index(),
+ comp->try_index(),
+ kAllocateObjectWithBoundsCheckRuntimeEntry);
+ __ popq(RCX); // Pop instantiator type arguments.
+ __ popq(RCX); // Pop type arguments.
+ __ popq(RCX); // Pop class.
+ __ popq(RCX); // Pop source location.
+ __ popq(RAX); // Pop new instance.
+}
+
+
void FlowGraphCompiler::VisitCreateArray(CreateArrayComp* comp) {
// 1. Allocate the array. R10 = length, RBX = element type.
__ movq(R10, Immediate(Smi::RawValue(comp->ElementCount())));
@@ -980,8 +992,8 @@
__ LoadObject(RCX, Class::ZoneHandle(Object::type_arguments_class()));
__ cmpq(RCX, FieldAddress(RAX, Object::class_offset()));
__ j(NOT_EQUAL, &type_arguments_uninstantiated, Assembler::kNearJump);
- Immediate arguments_length = Immediate(reinterpret_cast<int64_t>(
- Smi::New(comp->type_arguments().Length())));
+ Immediate arguments_length =
+ Immediate(Smi::RawValue(comp->type_arguments().Length()));
__ cmpq(FieldAddress(RAX, TypeArguments::length_offset()),
arguments_length);
__ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump);
@@ -1030,8 +1042,8 @@
__ LoadObject(RCX, Class::ZoneHandle(Object::type_arguments_class()));
__ cmpq(RCX, FieldAddress(RAX, Object::class_offset()));
__ j(NOT_EQUAL, &type_arguments_uninstantiated, Assembler::kNearJump);
- Immediate arguments_length = Immediate(reinterpret_cast<int64_t>(
- Smi::New(comp->type_arguments().Length())));
+ Immediate arguments_length =
+ Immediate(Smi::RawValue(comp->type_arguments().Length()));
__ cmpq(FieldAddress(RAX, TypeArguments::length_offset()),
arguments_length);
__ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump);
@@ -1086,8 +1098,8 @@
__ LoadObject(RCX, Class::ZoneHandle(Object::type_arguments_class()));
__ cmpq(RCX, FieldAddress(RAX, Object::class_offset()));
__ j(NOT_EQUAL, &done, Assembler::kNearJump);
- Immediate arguments_length = Immediate(reinterpret_cast<int64_t>(
- Smi::New(comp->type_arguments().Length())));
+ Immediate arguments_length =
+ Immediate(Smi::RawValue(comp->type_arguments().Length()));
__ cmpq(FieldAddress(RAX, TypeArguments::length_offset()),
arguments_length);
__ j(NOT_EQUAL, &done, Assembler::kNearJump);

Powered by Google App Engine
This is Rietveld 408576698