Index: src/x64/stub-cache-x64.cc |
=================================================================== |
--- src/x64/stub-cache-x64.cc (revision 5696) |
+++ src/x64/stub-cache-x64.cc (working copy) |
@@ -796,13 +796,16 @@ |
// Generate code to check that a global property cell is empty. Create |
// the property cell at compilation time if no cell exists for the |
// property. |
-static Object* GenerateCheckPropertyCell(MacroAssembler* masm, |
- GlobalObject* global, |
- String* name, |
- Register scratch, |
- Label* miss) { |
- Object* probe = global->EnsurePropertyCell(name); |
- if (probe->IsFailure()) return probe; |
+MUST_USE_RESULT static MaybeObject* GenerateCheckPropertyCell( |
+ MacroAssembler* masm, |
+ GlobalObject* global, |
+ String* name, |
+ Register scratch, |
+ Label* miss) { |
+ Object* probe; |
+ { MaybeObject* maybe_probe = global->EnsurePropertyCell(name); |
+ if (!maybe_probe->ToObject(&probe)) return maybe_probe; |
+ } |
JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(probe); |
ASSERT(cell->value()->IsTheHole()); |
__ Move(scratch, Handle<Object>(cell)); |
@@ -879,19 +882,23 @@ |
} |
-Object* CallStubCompiler::GenerateMissBranch() { |
- Object* obj = StubCache::ComputeCallMiss(arguments().immediate(), kind_); |
- if (obj->IsFailure()) return obj; |
+MaybeObject* CallStubCompiler::GenerateMissBranch() { |
+ Object* obj; |
+ { MaybeObject* maybe_obj = |
+ StubCache::ComputeCallMiss(arguments().immediate(), kind_); |
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
+ } |
__ Jump(Handle<Code>(Code::cast(obj)), RelocInfo::CODE_TARGET); |
return obj; |
} |
-Object* CallStubCompiler::CompileCallConstant(Object* object, |
- JSObject* holder, |
- JSFunction* function, |
- String* name, |
- StubCompiler::CheckType check) { |
+MaybeObject* CallStubCompiler::CompileCallConstant( |
+ Object* object, |
+ JSObject* holder, |
+ JSFunction* function, |
+ String* name, |
+ StubCompiler::CheckType check) { |
// ----------- S t a t e ------------- |
// rcx : function name |
// rsp[0] : return address |
@@ -905,8 +912,10 @@ |
SharedFunctionInfo* function_info = function->shared(); |
if (function_info->HasCustomCallGenerator()) { |
const int id = function_info->custom_call_generator_id(); |
- Object* result = CompileCustomCall( |
+ MaybeObject* maybe_result = CompileCustomCall( |
id, object, holder, NULL, function, name); |
+ Object* result; |
+ if (!maybe_result->ToObject(&result)) return maybe_result; |
// undefined means bail out to regular compiler. |
if (!result->IsUndefined()) return result; |
} |
@@ -1034,18 +1043,20 @@ |
// Handle call cache miss. |
__ bind(&miss_in_smi_check); |
- Object* obj = GenerateMissBranch(); |
- if (obj->IsFailure()) return obj; |
+ Object* obj; |
+ { MaybeObject* maybe_obj = GenerateMissBranch(); |
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
+ } |
// Return the generated code. |
return GetCode(function); |
} |
-Object* CallStubCompiler::CompileCallField(JSObject* object, |
- JSObject* holder, |
- int index, |
- String* name) { |
+MaybeObject* CallStubCompiler::CompileCallField(JSObject* object, |
+ JSObject* holder, |
+ int index, |
+ String* name) { |
// ----------- S t a t e ------------- |
// rcx : function name |
// rsp[0] : return address |
@@ -1089,19 +1100,21 @@ |
// Handle call cache miss. |
__ bind(&miss); |
- Object* obj = GenerateMissBranch(); |
- if (obj->IsFailure()) return obj; |
+ Object* obj; |
+ { MaybeObject* maybe_obj = GenerateMissBranch(); |
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
+ } |
// Return the generated code. |
return GetCode(FIELD, name); |
} |
-Object* CallStubCompiler::CompileArrayPushCall(Object* object, |
- JSObject* holder, |
- JSGlobalPropertyCell* cell, |
- JSFunction* function, |
- String* name) { |
+MaybeObject* CallStubCompiler::CompileArrayPushCall(Object* object, |
+ JSObject* holder, |
+ JSGlobalPropertyCell* cell, |
+ JSFunction* function, |
+ String* name) { |
// ----------- S t a t e ------------- |
// -- rcx : name |
// -- rsp[0] : return address |
@@ -1251,19 +1264,21 @@ |
} |
__ bind(&miss); |
- Object* obj = GenerateMissBranch(); |
- if (obj->IsFailure()) return obj; |
+ Object* obj; |
+ { MaybeObject* maybe_obj = GenerateMissBranch(); |
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
+ } |
// Return the generated code. |
return GetCode(function); |
} |
-Object* CallStubCompiler::CompileArrayPopCall(Object* object, |
- JSObject* holder, |
- JSGlobalPropertyCell* cell, |
- JSFunction* function, |
- String* name) { |
+MaybeObject* CallStubCompiler::CompileArrayPopCall(Object* object, |
+ JSObject* holder, |
+ JSGlobalPropertyCell* cell, |
+ JSFunction* function, |
+ String* name) { |
// ----------- S t a t e ------------- |
// -- rcx : name |
// -- rsp[0] : return address |
@@ -1333,19 +1348,22 @@ |
1); |
__ bind(&miss); |
- Object* obj = GenerateMissBranch(); |
- if (obj->IsFailure()) return obj; |
+ Object* obj; |
+ { MaybeObject* maybe_obj = GenerateMissBranch(); |
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
+ } |
// Return the generated code. |
return GetCode(function); |
} |
-Object* CallStubCompiler::CompileStringCharAtCall(Object* object, |
- JSObject* holder, |
- JSGlobalPropertyCell* cell, |
- JSFunction* function, |
- String* name) { |
+MaybeObject* CallStubCompiler::CompileStringCharAtCall( |
+ Object* object, |
+ JSObject* holder, |
+ JSGlobalPropertyCell* cell, |
+ JSFunction* function, |
+ String* name) { |
// ----------- S t a t e ------------- |
// -- rcx : function name |
// -- rsp[0] : return address |
@@ -1405,15 +1423,17 @@ |
__ ret((argc + 1) * kPointerSize); |
__ bind(&miss); |
- Object* obj = GenerateMissBranch(); |
- if (obj->IsFailure()) return obj; |
+ Object* obj; |
+ { MaybeObject* maybe_obj = GenerateMissBranch(); |
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
+ } |
// Return the generated code. |
return GetCode(function); |
} |
-Object* CallStubCompiler::CompileStringCharCodeAtCall( |
+MaybeObject* CallStubCompiler::CompileStringCharCodeAtCall( |
Object* object, |
JSObject* holder, |
JSGlobalPropertyCell* cell, |
@@ -1475,15 +1495,17 @@ |
__ ret((argc + 1) * kPointerSize); |
__ bind(&miss); |
- Object* obj = GenerateMissBranch(); |
- if (obj->IsFailure()) return obj; |
+ Object* obj; |
+ { MaybeObject* maybe_obj = GenerateMissBranch(); |
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
+ } |
// Return the generated code. |
return GetCode(function); |
} |
-Object* CallStubCompiler::CompileStringFromCharCodeCall( |
+MaybeObject* CallStubCompiler::CompileStringFromCharCodeCall( |
Object* object, |
JSObject* holder, |
JSGlobalPropertyCell* cell, |
@@ -1544,29 +1566,31 @@ |
__ bind(&miss); |
// rcx: function name. |
- Object* obj = GenerateMissBranch(); |
- if (obj->IsFailure()) return obj; |
+ Object* obj; |
+ { MaybeObject* maybe_obj = GenerateMissBranch(); |
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
+ } |
// Return the generated code. |
return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name); |
} |
-Object* CallStubCompiler::CompileMathFloorCall(Object* object, |
- JSObject* holder, |
- JSGlobalPropertyCell* cell, |
- JSFunction* function, |
- String* name) { |
+MaybeObject* CallStubCompiler::CompileMathFloorCall(Object* object, |
+ JSObject* holder, |
+ JSGlobalPropertyCell* cell, |
+ JSFunction* function, |
+ String* name) { |
// TODO(872): implement this. |
return Heap::undefined_value(); |
} |
-Object* CallStubCompiler::CompileMathAbsCall(Object* object, |
- JSObject* holder, |
- JSGlobalPropertyCell* cell, |
- JSFunction* function, |
- String* name) { |
+MaybeObject* CallStubCompiler::CompileMathAbsCall(Object* object, |
+ JSObject* holder, |
+ JSGlobalPropertyCell* cell, |
+ JSFunction* function, |
+ String* name) { |
// ----------- S t a t e ------------- |
// -- rcx : function name |
// -- rsp[0] : return address |
@@ -1657,17 +1681,19 @@ |
__ bind(&miss); |
// rcx: function name. |
- Object* obj = GenerateMissBranch(); |
- if (obj->IsFailure()) return obj; |
+ Object* obj; |
+ { MaybeObject* maybe_obj = GenerateMissBranch(); |
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
+ } |
// Return the generated code. |
return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name); |
} |
-Object* CallStubCompiler::CompileCallInterceptor(JSObject* object, |
- JSObject* holder, |
- String* name) { |
+MaybeObject* CallStubCompiler::CompileCallInterceptor(JSObject* object, |
+ JSObject* holder, |
+ String* name) { |
// ----------- S t a t e ------------- |
// rcx : function name |
// rsp[0] : return address |
@@ -1723,19 +1749,21 @@ |
// Handle load cache miss. |
__ bind(&miss); |
- Object* obj = GenerateMissBranch(); |
- if (obj->IsFailure()) return obj; |
+ Object* obj; |
+ { MaybeObject* maybe_obj = GenerateMissBranch(); |
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
+ } |
// Return the generated code. |
return GetCode(INTERCEPTOR, name); |
} |
-Object* CallStubCompiler::CompileCallGlobal(JSObject* object, |
- GlobalObject* holder, |
- JSGlobalPropertyCell* cell, |
- JSFunction* function, |
- String* name) { |
+MaybeObject* CallStubCompiler::CompileCallGlobal(JSObject* object, |
+ GlobalObject* holder, |
+ JSGlobalPropertyCell* cell, |
+ JSFunction* function, |
+ String* name) { |
// ----------- S t a t e ------------- |
// rcx : function name |
// rsp[0] : return address |
@@ -1749,8 +1777,10 @@ |
SharedFunctionInfo* function_info = function->shared(); |
if (function_info->HasCustomCallGenerator()) { |
const int id = function_info->custom_call_generator_id(); |
- Object* result = CompileCustomCall( |
+ MaybeObject* maybe_result = CompileCustomCall( |
id, object, holder, cell, function, name); |
+ Object* result; |
+ if (!maybe_result->ToObject(&result)) return maybe_result; |
// undefined means bail out to regular compiler. |
if (!result->IsUndefined()) return result; |
} |
@@ -1786,18 +1816,20 @@ |
// Handle call cache miss. |
__ bind(&miss); |
__ IncrementCounter(&Counters::call_global_inline_miss, 1); |
- Object* obj = GenerateMissBranch(); |
- if (obj->IsFailure()) return obj; |
+ Object* obj; |
+ { MaybeObject* maybe_obj = GenerateMissBranch(); |
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
+ } |
// Return the generated code. |
return GetCode(NORMAL, name); |
} |
-Object* LoadStubCompiler::CompileLoadCallback(String* name, |
- JSObject* object, |
- JSObject* holder, |
- AccessorInfo* callback) { |
+MaybeObject* LoadStubCompiler::CompileLoadCallback(String* name, |
+ JSObject* object, |
+ JSObject* holder, |
+ AccessorInfo* callback) { |
// ----------- S t a t e ------------- |
// -- rax : receiver |
// -- rcx : name |
@@ -1821,10 +1853,10 @@ |
} |
-Object* LoadStubCompiler::CompileLoadConstant(JSObject* object, |
- JSObject* holder, |
- Object* value, |
- String* name) { |
+MaybeObject* LoadStubCompiler::CompileLoadConstant(JSObject* object, |
+ JSObject* holder, |
+ Object* value, |
+ String* name) { |
// ----------- S t a t e ------------- |
// -- rax : receiver |
// -- rcx : name |
@@ -1841,9 +1873,9 @@ |
} |
-Object* LoadStubCompiler::CompileLoadNonexistent(String* name, |
- JSObject* object, |
- JSObject* last) { |
+MaybeObject* LoadStubCompiler::CompileLoadNonexistent(String* name, |
+ JSObject* object, |
+ JSObject* last) { |
// ----------- S t a t e ------------- |
// -- rax : receiver |
// -- rcx : name |
@@ -1862,11 +1894,11 @@ |
// If the last object in the prototype chain is a global object, |
// check that the global property cell is empty. |
if (last->IsGlobalObject()) { |
- Object* cell = GenerateCheckPropertyCell(masm(), |
- GlobalObject::cast(last), |
- name, |
- rdx, |
- &miss); |
+ MaybeObject* cell = GenerateCheckPropertyCell(masm(), |
+ GlobalObject::cast(last), |
+ name, |
+ rdx, |
+ &miss); |
if (cell->IsFailure()) { |
miss.Unuse(); |
return cell; |
@@ -1886,10 +1918,10 @@ |
} |
-Object* LoadStubCompiler::CompileLoadField(JSObject* object, |
- JSObject* holder, |
- int index, |
- String* name) { |
+MaybeObject* LoadStubCompiler::CompileLoadField(JSObject* object, |
+ JSObject* holder, |
+ int index, |
+ String* name) { |
// ----------- S t a t e ------------- |
// -- rax : receiver |
// -- rcx : name |
@@ -1906,9 +1938,9 @@ |
} |
-Object* LoadStubCompiler::CompileLoadInterceptor(JSObject* receiver, |
- JSObject* holder, |
- String* name) { |
+MaybeObject* LoadStubCompiler::CompileLoadInterceptor(JSObject* receiver, |
+ JSObject* holder, |
+ String* name) { |
// ----------- S t a t e ------------- |
// -- rax : receiver |
// -- rcx : name |
@@ -1940,11 +1972,11 @@ |
} |
-Object* LoadStubCompiler::CompileLoadGlobal(JSObject* object, |
- GlobalObject* holder, |
- JSGlobalPropertyCell* cell, |
- String* name, |
- bool is_dont_delete) { |
+MaybeObject* LoadStubCompiler::CompileLoadGlobal(JSObject* object, |
+ GlobalObject* holder, |
+ JSGlobalPropertyCell* cell, |
+ String* name, |
+ bool is_dont_delete) { |
// ----------- S t a t e ------------- |
// -- rax : receiver |
// -- rcx : name |
@@ -1988,10 +2020,11 @@ |
} |
-Object* KeyedLoadStubCompiler::CompileLoadCallback(String* name, |
- JSObject* receiver, |
- JSObject* holder, |
- AccessorInfo* callback) { |
+MaybeObject* KeyedLoadStubCompiler::CompileLoadCallback( |
+ String* name, |
+ JSObject* receiver, |
+ JSObject* holder, |
+ AccessorInfo* callback) { |
// ----------- S t a t e ------------- |
// -- rax : key |
// -- rdx : receiver |
@@ -2022,7 +2055,7 @@ |
} |
-Object* KeyedLoadStubCompiler::CompileLoadArrayLength(String* name) { |
+MaybeObject* KeyedLoadStubCompiler::CompileLoadArrayLength(String* name) { |
// ----------- S t a t e ------------- |
// -- rax : key |
// -- rdx : receiver |
@@ -2046,10 +2079,10 @@ |
} |
-Object* KeyedLoadStubCompiler::CompileLoadConstant(String* name, |
- JSObject* receiver, |
- JSObject* holder, |
- Object* value) { |
+MaybeObject* KeyedLoadStubCompiler::CompileLoadConstant(String* name, |
+ JSObject* receiver, |
+ JSObject* holder, |
+ Object* value) { |
// ----------- S t a t e ------------- |
// -- rax : key |
// -- rdx : receiver |
@@ -2074,7 +2107,7 @@ |
} |
-Object* KeyedLoadStubCompiler::CompileLoadFunctionPrototype(String* name) { |
+MaybeObject* KeyedLoadStubCompiler::CompileLoadFunctionPrototype(String* name) { |
// ----------- S t a t e ------------- |
// -- rax : key |
// -- rdx : receiver |
@@ -2098,9 +2131,9 @@ |
} |
-Object* KeyedLoadStubCompiler::CompileLoadInterceptor(JSObject* receiver, |
- JSObject* holder, |
- String* name) { |
+MaybeObject* KeyedLoadStubCompiler::CompileLoadInterceptor(JSObject* receiver, |
+ JSObject* holder, |
+ String* name) { |
// ----------- S t a t e ------------- |
// -- rax : key |
// -- rdx : receiver |
@@ -2135,7 +2168,7 @@ |
} |
-Object* KeyedLoadStubCompiler::CompileLoadStringLength(String* name) { |
+MaybeObject* KeyedLoadStubCompiler::CompileLoadStringLength(String* name) { |
// ----------- S t a t e ------------- |
// -- rax : key |
// -- rdx : receiver |
@@ -2159,9 +2192,9 @@ |
} |
-Object* StoreStubCompiler::CompileStoreCallback(JSObject* object, |
- AccessorInfo* callback, |
- String* name) { |
+MaybeObject* StoreStubCompiler::CompileStoreCallback(JSObject* object, |
+ AccessorInfo* callback, |
+ String* name) { |
// ----------- S t a t e ------------- |
// -- rax : value |
// -- rcx : name |
@@ -2209,10 +2242,10 @@ |
} |
-Object* StoreStubCompiler::CompileStoreField(JSObject* object, |
- int index, |
- Map* transition, |
- String* name) { |
+MaybeObject* StoreStubCompiler::CompileStoreField(JSObject* object, |
+ int index, |
+ Map* transition, |
+ String* name) { |
// ----------- S t a t e ------------- |
// -- rax : value |
// -- rcx : name |
@@ -2239,8 +2272,8 @@ |
} |
-Object* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver, |
- String* name) { |
+MaybeObject* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver, |
+ String* name) { |
// ----------- S t a t e ------------- |
// -- rax : value |
// -- rcx : name |
@@ -2287,9 +2320,9 @@ |
} |
-Object* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object, |
- JSGlobalPropertyCell* cell, |
- String* name) { |
+MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object, |
+ JSGlobalPropertyCell* cell, |
+ String* name) { |
// ----------- S t a t e ------------- |
// -- rax : value |
// -- rcx : name |
@@ -2322,10 +2355,10 @@ |
} |
-Object* KeyedLoadStubCompiler::CompileLoadField(String* name, |
- JSObject* receiver, |
- JSObject* holder, |
- int index) { |
+MaybeObject* KeyedLoadStubCompiler::CompileLoadField(String* name, |
+ JSObject* receiver, |
+ JSObject* holder, |
+ int index) { |
// ----------- S t a t e ------------- |
// -- rax : key |
// -- rdx : receiver |
@@ -2350,10 +2383,10 @@ |
} |
-Object* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, |
- int index, |
- Map* transition, |
- String* name) { |
+MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, |
+ int index, |
+ Map* transition, |
+ String* name) { |
// ----------- S t a t e ------------- |
// -- rax : value |
// -- rcx : key |
@@ -2591,7 +2624,7 @@ |
// already generated). Do not allow the assembler to perform a |
// garbage collection but instead return the allocation failure |
// object. |
- Object* result = masm()->TryCallStub(&stub); |
+ MaybeObject* result = masm()->TryCallStub(&stub); |
if (result->IsFailure()) { |
*failure = Failure::cast(result); |
return false; |
@@ -2647,12 +2680,12 @@ |
!current->IsJSGlobalObject() && |
!current->IsJSGlobalProxy()) { |
if (!name->IsSymbol()) { |
- Object* lookup_result = Heap::LookupSymbol(name); |
+ MaybeObject* lookup_result = Heap::LookupSymbol(name); |
if (lookup_result->IsFailure()) { |
set_failure(Failure::cast(lookup_result)); |
return reg; |
} else { |
- name = String::cast(lookup_result); |
+ name = String::cast(lookup_result->ToObjectUnchecked()); |
} |
} |
ASSERT(current->property_dictionary()->FindEntry(name) == |
@@ -2734,11 +2767,11 @@ |
current = object; |
while (current != holder) { |
if (current->IsGlobalObject()) { |
- Object* cell = GenerateCheckPropertyCell(masm(), |
- GlobalObject::cast(current), |
- name, |
- scratch1, |
- miss); |
+ MaybeObject* cell = GenerateCheckPropertyCell(masm(), |
+ GlobalObject::cast(current), |
+ name, |
+ scratch1, |
+ miss); |
if (cell->IsFailure()) { |
set_failure(Failure::cast(cell)); |
return reg; |
@@ -2800,7 +2833,7 @@ |
// Specialized stub for constructing objects from functions which only have only |
// simple assignments of the form this.x = ...; in their body. |
-Object* ConstructStubCompiler::CompileConstructStub( |
+MaybeObject* ConstructStubCompiler::CompileConstructStub( |
SharedFunctionInfo* shared) { |
// ----------- S t a t e ------------- |
// -- rax : argc |