Revision: 9791
Author: [email protected]
Date: Wed Oct 26 03:45:24 2011
Log: Handlify simple functions of [keyed] store stub compiler.
Handlified functions: CompileStoreField, CompileStoreGlobal,
CompileStoreElement, CompileStorePolymorphic.
Based on 8375053.
[email protected]
BUG=
TEST=
Review URL: http://codereview.chromium.org/8393003
http://code.google.com/p/v8/source/detail?r=9791
Modified:
/branches/bleeding_edge/src/arm/stub-cache-arm.cc
/branches/bleeding_edge/src/ia32/stub-cache-ia32.cc
/branches/bleeding_edge/src/list-inl.h
/branches/bleeding_edge/src/list.h
/branches/bleeding_edge/src/stub-cache.cc
/branches/bleeding_edge/src/stub-cache.h
/branches/bleeding_edge/src/x64/stub-cache-x64.cc
=======================================
--- /branches/bleeding_edge/src/arm/stub-cache-arm.cc Wed Oct 26 02:58:32
2011
+++ /branches/bleeding_edge/src/arm/stub-cache-arm.cc Wed Oct 26 03:45:24
2011
@@ -425,9 +425,9 @@
// may be clobbered. Upon branch to miss_label, the receiver and name
// registers have their original values.
void StubCompiler::GenerateStoreField(MacroAssembler* masm,
- JSObject* object,
+ Handle<JSObject> object,
int index,
- Map* transition,
+ Handle<Map> transition,
Register receiver_reg,
Register name_reg,
Register scratch,
@@ -453,11 +453,11 @@
ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded());
// Perform map transition for the receiver if necessary.
- if ((transition != NULL) && (object->map()->unused_property_fields() ==
0)) {
+ if (!transition.is_null() && (object->map()->unused_property_fields() ==
0)) {
// The properties must be extended before we can store the value.
// We jump to a runtime call that extends the properties array.
__ push(receiver_reg);
- __ mov(r2, Operand(Handle<Map>(transition)));
+ __ mov(r2, Operand(transition));
__ Push(r2, r0);
__ TailCallExternalReference(
ExternalReference(IC_Utility(IC::kSharedStoreIC_ExtendStorage),
@@ -467,10 +467,10 @@
return;
}
- if (transition != NULL) {
+ if (!transition.is_null()) {
// Update the map of the object; no write barrier updating is
// needed because the map is never in new space.
- __ mov(ip, Operand(Handle<Map>(transition)));
+ __ mov(ip, Operand(transition));
__ str(ip, FieldMemOperand(receiver_reg, HeapObject::kMapOffset));
}
@@ -2821,10 +2821,10 @@
}
-MaybeObject* StoreStubCompiler::CompileStoreField(JSObject* object,
+Handle<Code> StoreStubCompiler::CompileStoreField(Handle<JSObject> object,
int index,
- Map* transition,
- String* name) {
+ Handle<Map> transition,
+ Handle<String> name) {
// ----------- S t a t e -------------
// -- r0 : value
// -- r1 : receiver
@@ -2833,18 +2833,13 @@
// -----------------------------------
Label miss;
- GenerateStoreField(masm(),
- object,
- index,
- transition,
- r1, r2, r3,
- &miss);
+ GenerateStoreField(masm(), object, index, transition, r1, r2, r3, &miss);
__ bind(&miss);
Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss();
__ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name);
+ return GetCode(transition.is_null() ? FIELD : MAP_TRANSITION, name);
}
@@ -2892,7 +2887,7 @@
__ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(CALLBACKS, name);
+ return TryGetCode(CALLBACKS, name);
}
@@ -2940,13 +2935,14 @@
__ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(INTERCEPTOR, name);
+ return TryGetCode(INTERCEPTOR, name);
}
-MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object,
- JSGlobalPropertyCell*
cell,
- String* name) {
+Handle<Code> StoreStubCompiler::CompileStoreGlobal(
+ Handle<GlobalObject> object,
+ Handle<JSGlobalPropertyCell> cell,
+ Handle<String> name) {
// ----------- S t a t e -------------
// -- r0 : value
// -- r1 : receiver
@@ -2964,7 +2960,7 @@
// cell could have been deleted and reintroducing the global needs
// to update the property details in the property dictionary of the
// global object. We bail out to the runtime system to do that.
- __ mov(r4, Operand(Handle<JSGlobalPropertyCell>(cell)));
+ __ mov(r4, Operand(cell));
__ LoadRoot(r5, Heap::kTheHoleValueRootIndex);
__ ldr(r6, FieldMemOperand(r4, JSGlobalPropertyCell::kValueOffset));
__ cmp(r5, r6);
@@ -3407,10 +3403,10 @@
}
-MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
+Handle<Code> KeyedStoreStubCompiler::CompileStoreField(Handle<JSObject>
object,
int index,
- Map* transition,
- String* name) {
+ Handle<Map>
transition,
+ Handle<String>
name) {
// ----------- S t a t e -------------
// -- r0 : value
// -- r1 : name
@@ -3423,17 +3419,12 @@
__ IncrementCounter(counters->keyed_store_field(), 1, r3, r4);
// Check that the name has not changed.
- __ cmp(r1, Operand(Handle<String>(name)));
+ __ cmp(r1, Operand(name));
__ b(ne, &miss);
// r3 is used as scratch register. r1 and r2 keep their values if a jump
to
// the miss label is generated.
- GenerateStoreField(masm(),
- object,
- index,
- transition,
- r2, r1, r3,
- &miss);
+ GenerateStoreField(masm(), object, index, transition, r2, r1, r3, &miss);
__ bind(&miss);
__ DecrementCounter(counters->keyed_store_field(), 1, r3, r4);
@@ -3441,11 +3432,12 @@
__ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name);
+ return GetCode(transition.is_null() ? FIELD : MAP_TRANSITION, name);
}
-MaybeObject* KeyedStoreStubCompiler::CompileStoreElement(Map*
receiver_map) {
+Handle<Code> KeyedStoreStubCompiler::CompileStoreElement(
+ Handle<Map> receiver_map) {
// ----------- S t a t e -------------
// -- r0 : value
// -- r1 : key
@@ -3453,30 +3445,25 @@
// -- lr : return address
// -- r3 : scratch
// -----------------------------------
- Code* stub;
ElementsKind elements_kind = receiver_map->elements_kind();
bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
- MaybeObject* maybe_stub =
- KeyedStoreElementStub(is_js_array, elements_kind).TryGetCode();
- if (!maybe_stub->To(&stub)) return maybe_stub;
- __ DispatchMap(r2,
- r3,
- Handle<Map>(receiver_map),
- Handle<Code>(stub),
- DO_SMI_CHECK);
+ Handle<Code> stub =
+ KeyedStoreElementStub(is_js_array, elements_kind).GetCode();
+
+ __ DispatchMap(r2, r3, receiver_map, stub, DO_SMI_CHECK);
Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
__ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(NORMAL, NULL);
+ return GetCode(NORMAL, factory()->empty_string());
}
-MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic(
- MapList* receiver_maps,
- CodeList* handler_stubs,
- MapList* transitioned_maps) {
+Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
+ MapHandleList* receiver_maps,
+ CodeHandleList* handler_stubs,
+ MapHandleList* transitioned_maps) {
// ----------- S t a t e -------------
// -- r0 : value
// -- r1 : key
@@ -3490,17 +3477,15 @@
int receiver_count = receiver_maps->length();
__ ldr(r3, FieldMemOperand(r2, HeapObject::kMapOffset));
for (int i = 0; i < receiver_count; ++i) {
- Handle<Map> map(receiver_maps->at(i));
- Handle<Code> code(handler_stubs->at(i));
- __ mov(ip, Operand(map));
+ __ mov(ip, Operand(receiver_maps->at(i)));
__ cmp(r3, ip);
- if (transitioned_maps->at(i) == NULL) {
- __ Jump(code, RelocInfo::CODE_TARGET, eq);
+ if (transitioned_maps->at(i).is_null()) {
+ __ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, eq);
} else {
Label next_map;
__ b(ne, &next_map);
- __ mov(r3, Operand(Handle<Map>(transitioned_maps->at(i))));
- __ Jump(code, RelocInfo::CODE_TARGET, al);
+ __ mov(r3, Operand(transitioned_maps->at(i)));
+ __ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, al);
__ bind(&next_map);
}
}
@@ -3510,7 +3495,7 @@
__ Jump(miss_ic, RelocInfo::CODE_TARGET, al);
// Return the generated code.
- return GetCode(NORMAL, NULL, MEGAMORPHIC);
+ return GetCode(NORMAL, factory()->empty_string(), MEGAMORPHIC);
}
=======================================
--- /branches/bleeding_edge/src/ia32/stub-cache-ia32.cc Wed Oct 26 02:58:32
2011
+++ /branches/bleeding_edge/src/ia32/stub-cache-ia32.cc Wed Oct 26 03:45:24
2011
@@ -772,9 +772,9 @@
// Both name_reg and receiver_reg are preserved on jumps to miss_label,
// but may be destroyed if store is successful.
void StubCompiler::GenerateStoreField(MacroAssembler* masm,
- JSObject* object,
+ Handle<JSObject> object,
int index,
- Map* transition,
+ Handle<Map> transition,
Register receiver_reg,
Register name_reg,
Register scratch,
@@ -797,12 +797,12 @@
ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded());
// Perform map transition for the receiver if necessary.
- if ((transition != NULL) && (object->map()->unused_property_fields() ==
0)) {
+ if (!transition.is_null() && (object->map()->unused_property_fields() ==
0)) {
// The properties must be extended before we can store the value.
// We jump to a runtime call that extends the properties array.
__ pop(scratch); // Return address.
__ push(receiver_reg);
- __ push(Immediate(Handle<Map>(transition)));
+ __ push(Immediate(transition));
__ push(eax);
__ push(scratch);
__ TailCallExternalReference(
@@ -813,11 +813,11 @@
return;
}
- if (transition != NULL) {
+ if (!transition.is_null()) {
// Update the map of the object; no write barrier updating is
// needed because the map is never in new space.
__ mov(FieldOperand(receiver_reg, HeapObject::kMapOffset),
- Immediate(Handle<Map>(transition)));
+ Immediate(transition));
}
// Adjust for the number of properties stored in the object. Even in the
@@ -2699,10 +2699,10 @@
}
-MaybeObject* StoreStubCompiler::CompileStoreField(JSObject* object,
+Handle<Code> StoreStubCompiler::CompileStoreField(Handle<JSObject> object,
int index,
- Map* transition,
- String* name) {
+ Handle<Map> transition,
+ Handle<String> name) {
// ----------- S t a t e -------------
// -- eax : value
// -- ecx : name
@@ -2712,21 +2712,16 @@
Label miss;
// Generate store field code. Trashes the name register.
- GenerateStoreField(masm(),
- object,
- index,
- transition,
- edx, ecx, ebx,
- &miss);
+ GenerateStoreField(masm(), object, index, transition, edx, ecx, ebx,
&miss);
// Handle store cache miss.
__ bind(&miss);
- __ mov(ecx, Immediate(Handle<String>(name))); // restore name
+ __ mov(ecx, Immediate(name)); // restore name
Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
__ jmp(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name);
+ return GetCode(transition.is_null() ? FIELD : MAP_TRANSITION, name);
}
@@ -2776,7 +2771,7 @@
__ jmp(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(CALLBACKS, name);
+ return TryGetCode(CALLBACKS, name);
}
@@ -2825,13 +2820,14 @@
__ jmp(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(INTERCEPTOR, name);
+ return TryGetCode(INTERCEPTOR, name);
}
-MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object,
- JSGlobalPropertyCell*
cell,
- String* name) {
+Handle<Code> StoreStubCompiler::CompileStoreGlobal(
+ Handle<GlobalObject> object,
+ Handle<JSGlobalPropertyCell> cell,
+ Handle<String> name) {
// ----------- S t a t e -------------
// -- eax : value
// -- ecx : name
@@ -2846,7 +2842,7 @@
__ j(not_equal, &miss);
// Compute the cell operand to use.
- __ mov(ebx, Immediate(Handle<JSGlobalPropertyCell>(cell)));
+ __ mov(ebx, Immediate(cell));
Operand cell_operand = FieldOperand(ebx,
JSGlobalPropertyCell::kValueOffset);
// Check that the value in the cell is not the hole. If it is, this
@@ -2890,10 +2886,10 @@
}
-MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
+Handle<Code> KeyedStoreStubCompiler::CompileStoreField(Handle<JSObject>
object,
int index,
- Map* transition,
- String* name) {
+ Handle<Map>
transition,
+ Handle<String>
name) {
// ----------- S t a t e -------------
// -- eax : value
// -- ecx : key
@@ -2906,16 +2902,11 @@
__ IncrementCounter(counters->keyed_store_field(), 1);
// Check that the name has not changed.
- __ cmp(ecx, Immediate(Handle<String>(name)));
+ __ cmp(ecx, Immediate(name));
__ j(not_equal, &miss);
// Generate store field code. Trashes the name register.
- GenerateStoreField(masm(),
- object,
- index,
- transition,
- edx, ecx, ebx,
- &miss);
+ GenerateStoreField(masm(), object, index, transition, edx, ecx, ebx,
&miss);
// Handle store cache miss.
__ bind(&miss);
@@ -2924,40 +2915,37 @@
__ jmp(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name);
+ return GetCode(transition.is_null() ? FIELD : MAP_TRANSITION, name);
}
-MaybeObject* KeyedStoreStubCompiler::CompileStoreElement(Map*
receiver_map) {
+Handle<Code> KeyedStoreStubCompiler::CompileStoreElement(
+ Handle<Map> receiver_map) {
// ----------- S t a t e -------------
// -- eax : value
// -- ecx : key
// -- edx : receiver
// -- esp[0] : return address
// -----------------------------------
- Code* stub;
ElementsKind elements_kind = receiver_map->elements_kind();
bool is_jsarray = receiver_map->instance_type() == JS_ARRAY_TYPE;
- MaybeObject* maybe_stub =
- KeyedStoreElementStub(is_jsarray, elements_kind).TryGetCode();
- if (!maybe_stub->To(&stub)) return maybe_stub;
- __ DispatchMap(edx,
- Handle<Map>(receiver_map),
- Handle<Code>(stub),
- DO_SMI_CHECK);
+ Handle<Code> stub =
+ KeyedStoreElementStub(is_jsarray, elements_kind).GetCode();
+
+ __ DispatchMap(edx, receiver_map, stub, DO_SMI_CHECK);
Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
__ jmp(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(NORMAL, NULL);
+ return GetCode(NORMAL, factory()->empty_string());
}
-MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic(
- MapList* receiver_maps,
- CodeList* handler_stubs,
- MapList* transitioned_maps) {
+Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
+ MapHandleList* receiver_maps,
+ CodeHandleList* handler_stubs,
+ MapHandleList* transitioned_maps) {
// ----------- S t a t e -------------
// -- eax : value
// -- ecx : key
@@ -2969,15 +2957,14 @@
__ mov(edi, FieldOperand(edx, HeapObject::kMapOffset));
// ebx: receiver->map().
for (int i = 0; i < receiver_maps->length(); ++i) {
- Handle<Map> map(receiver_maps->at(i));
- __ cmp(edi, map);
- if (transitioned_maps->at(i) == NULL) {
- __ j(equal, Handle<Code>(handler_stubs->at(i)));
+ __ cmp(edi, receiver_maps->at(i));
+ if (transitioned_maps->at(i).is_null()) {
+ __ j(equal, handler_stubs->at(i));
} else {
Label next_map;
__ j(not_equal, &next_map, Label::kNear);
- __ mov(ebx, Immediate(Handle<Map>(transitioned_maps->at(i))));
- __ jmp(Handle<Code>(handler_stubs->at(i)), RelocInfo::CODE_TARGET);
+ __ mov(ebx, Immediate(transitioned_maps->at(i)));
+ __ jmp(handler_stubs->at(i), RelocInfo::CODE_TARGET);
__ bind(&next_map);
}
}
@@ -2986,7 +2973,7 @@
__ jmp(miss_ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(NORMAL, NULL, MEGAMORPHIC);
+ return GetCode(NORMAL, factory()->empty_string(), MEGAMORPHIC);
}
=======================================
--- /branches/bleeding_edge/src/list-inl.h Fri Oct 21 04:42:54 2011
+++ /branches/bleeding_edge/src/list-inl.h Wed Oct 26 03:45:24 2011
@@ -235,18 +235,6 @@
int SortedListBSearch(const List<T>& list, T elem) {
return SortedListBSearch<T>(list, elem, PointerValueCompare<T>);
}
-
-
-template <class T>
-List<T*>* UnwrapHandleList(List<T*>* destination, List<Handle<T> >*
source) {
- ASSERT(destination->is_empty());
- int length = source->length();
- for (int i = 0; i < length; ++i) {
- Handle<T> handle = source->at(i);
- destination->Add(handle.is_null() ? NULL : *handle);
- }
- return destination;
-}
} } // namespace v8::internal
=======================================
--- /branches/bleeding_edge/src/list.h Fri Oct 21 04:42:54 2011
+++ /branches/bleeding_edge/src/list.h Wed Oct 26 03:45:24 2011
@@ -179,14 +179,6 @@
template <typename T>
int SortedListBSearch(const List<T>& list, T elem);
-// Unwraps each handle in the source list to a pointer at
-// the corresponding position in the destination list.
-// Returns the destination list.
-// Both list must have the same length.
-
-template <class T>
-List<T*>* UnwrapHandleList(List<T*>* destination, List<Handle<T> >*
source);
-
} } // namespace v8::internal
=======================================
--- /branches/bleeding_edge/src/stub-cache.cc Wed Oct 26 02:58:32 2011
+++ /branches/bleeding_edge/src/stub-cache.cc Wed Oct 26 03:45:24 2011
@@ -415,20 +415,6 @@
JSObject::UpdateMapCodeCache(receiver, name, code);
return code;
}
-
-
-Handle<Code> StoreStubCompiler::CompileStoreField(Handle<JSObject> object,
- int index,
- Handle<Map> transition,
- Handle<String> name) {
- CALL_HEAP_FUNCTION(
- isolate(),
- (set_failure(NULL),
- CompileStoreField(*object, index,
- transition.is_null() ? NULL : *transition,
- *name)),
- Code);
-}
Handle<Code> StubCache::ComputeStoreField(Handle<String> name,
@@ -450,14 +436,6 @@
JSObject::UpdateMapCodeCache(receiver, name, code);
return code;
}
-
-
-Handle<Code> KeyedStoreStubCompiler::CompileStoreElement(Handle<Map> map) {
- CALL_HEAP_FUNCTION(isolate(),
- (set_failure(NULL),
- CompileStoreElement(*map)),
- Code);
-}
Handle<Code> StubCache::ComputeKeyedLoadOrStoreElement(
@@ -513,29 +491,6 @@
JSObject::UpdateMapCodeCache(receiver, name, code);
return code;
}
-
-
-Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
- MapHandleList* receiver_maps,
- CodeHandleList* handler_stubs,
- MapHandleList* transitioned_maps) {
- MapList raw_receiver_maps(receiver_maps->length());
- CodeList raw_handler_stubs(handler_stubs->length());
- MapList raw_transitioned_maps(transitioned_maps->length());
- CALL_HEAP_FUNCTION(
- isolate(),
- (set_failure(NULL),
- raw_receiver_maps.Clear(),
- raw_handler_stubs.Clear(),
- raw_transitioned_maps.Clear(),
- CompileStorePolymorphic(UnwrapHandleList(&raw_receiver_maps,
- receiver_maps),
- UnwrapHandleList(&raw_handler_stubs,
- handler_stubs),
- UnwrapHandleList(&raw_transitioned_maps,
- transitioned_maps))),
- Code);
-}
Handle<Code> StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) {
@@ -543,17 +498,6 @@
? isolate_->builtins()->Builtins::StoreIC_Normal_Strict()
: isolate_->builtins()->Builtins::StoreIC_Normal();
}
-
-
-Handle<Code> StoreStubCompiler::CompileStoreGlobal(
- Handle<GlobalObject> object,
- Handle<JSGlobalPropertyCell> holder,
- Handle<String> name) {
- CALL_HEAP_FUNCTION(isolate(),
- (set_failure(NULL),
- CompileStoreGlobal(*object, *holder, *name)),
- Code);
-}
Handle<Code> StubCache::ComputeStoreGlobal(Handle<String> name,
@@ -628,19 +572,6 @@
JSObject::UpdateMapCodeCache(receiver, name, code);
return code;
}
-
-Handle<Code> KeyedStoreStubCompiler::CompileStoreField(Handle<JSObject>
object,
- int index,
- Handle<Map>
transition,
- Handle<String>
name) {
- CALL_HEAP_FUNCTION(
- isolate(),
- (set_failure(NULL),
- CompileStoreField(*object, index,
- transition.is_null() ? NULL : *transition,
- *name)),
- Code);
-}
Handle<Code> StubCache::ComputeKeyedStoreField(Handle<String> name,
Handle<JSObject> receiver,
@@ -1616,7 +1547,20 @@
}
-MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) {
+Handle<Code> StoreStubCompiler::GetCode(PropertyType type,
+ Handle<String> name) {
+ Code::Flags flags =
+ Code::ComputeMonomorphicFlags(Code::STORE_IC, type, strict_mode_);
+ Handle<Code> code = GetCodeWithFlags(flags, name);
+ PROFILE(isolate(), CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name));
+ GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code));
+ return code;
+}
+
+
+// TODO(ulan): Eliminate this function when the stub cache is fully
+// handlified.
+MaybeObject* StoreStubCompiler::TryGetCode(PropertyType type, String*
name) {
Code::Flags flags =
Code::ComputeMonomorphicFlags(Code::STORE_IC, type, strict_mode_);
MaybeObject* result = TryGetCodeWithFlags(flags, name);
@@ -1633,22 +1577,15 @@
}
-MaybeObject* KeyedStoreStubCompiler::GetCode(PropertyType type,
- String* name,
+Handle<Code> KeyedStoreStubCompiler::GetCode(PropertyType type,
+ Handle<String> name,
InlineCacheState state) {
Code::Flags flags =
Code::ComputeFlags(Code::KEYED_STORE_IC, state, strict_mode_, type);
- MaybeObject* result = TryGetCodeWithFlags(flags, name);
- if (!result->IsFailure()) {
- PROFILE(isolate(),
- CodeCreateEvent(Logger::KEYED_STORE_IC_TAG,
- Code::cast(result->ToObjectUnchecked()),
- name));
- GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC,
- name,
- Code::cast(result->ToObjectUnchecked())));
- }
- return result;
+ Handle<Code> code = GetCodeWithFlags(flags, name);
+ PROFILE(isolate(), CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, *code,
*name));
+ GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, *name, *code));
+ return code;
}
=======================================
--- /branches/bleeding_edge/src/stub-cache.h Wed Oct 26 02:58:32 2011
+++ /branches/bleeding_edge/src/stub-cache.h Wed Oct 26 03:45:24 2011
@@ -440,9 +440,9 @@
Label* miss_label);
static void GenerateStoreField(MacroAssembler* masm,
- JSObject* object,
+ Handle<JSObject> object,
int index,
- Map* transition,
+ Handle<Map> transition,
Register receiver_reg,
Register name_reg,
Register scratch,
@@ -688,8 +688,8 @@
private:
MaybeObject* TryGetCode(PropertyType type,
- String* name,
- InlineCacheState state = MONOMORPHIC);
+ String* name,
+ InlineCacheState state = MONOMORPHIC);
Handle<Code> GetCode(PropertyType type,
Handle<String> name,
@@ -708,11 +708,6 @@
Handle<Map> transition,
Handle<String> name);
- MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object,
- int index,
- Map* transition,
- String* name);
-
Handle<Code> CompileStoreCallback(Handle<JSObject> object,
Handle<AccessorInfo> callback,
Handle<String> name);
@@ -730,13 +725,10 @@
Handle<JSGlobalPropertyCell> holder,
Handle<String> name);
- MUST_USE_RESULT MaybeObject* CompileStoreGlobal(GlobalObject* object,
- JSGlobalPropertyCell*
holder,
- String* name);
-
-
private:
- MaybeObject* GetCode(PropertyType type, String* name);
+ MaybeObject* TryGetCode(PropertyType type, String* name);
+
+ Handle<Code> GetCode(PropertyType type, Handle<String> name);
StrictModeFlag strict_mode_;
};
@@ -752,24 +744,12 @@
Handle<Map> transition,
Handle<String> name);
- MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object,
- int index,
- Map* transition,
- String* name);
-
Handle<Code> CompileStoreElement(Handle<Map> receiver_map);
- MUST_USE_RESULT MaybeObject* CompileStoreElement(Map* receiver_map);
-
Handle<Code> CompileStorePolymorphic(MapHandleList* receiver_maps,
CodeHandleList* handler_stubs,
MapHandleList* transitioned_maps);
- MUST_USE_RESULT MaybeObject* CompileStorePolymorphic(
- MapList* receiver_maps,
- CodeList* handler_stubs,
- MapList* transitioned_maps);
-
static void GenerateStoreFastElement(MacroAssembler* masm,
bool is_js_array,
ElementsKind element_kind);
@@ -783,8 +763,8 @@
static void GenerateStoreDictionaryElement(MacroAssembler* masm);
private:
- MaybeObject* GetCode(PropertyType type,
- String* name,
+ Handle<Code> GetCode(PropertyType type,
+ Handle<String> name,
InlineCacheState state = MONOMORPHIC);
StrictModeFlag strict_mode_;
=======================================
--- /branches/bleeding_edge/src/x64/stub-cache-x64.cc Wed Oct 26 02:58:32
2011
+++ /branches/bleeding_edge/src/x64/stub-cache-x64.cc Wed Oct 26 03:45:24
2011
@@ -768,9 +768,9 @@
// Both name_reg and receiver_reg are preserved on jumps to miss_label,
// but may be destroyed if store is successful.
void StubCompiler::GenerateStoreField(MacroAssembler* masm,
- JSObject* object,
+ Handle<JSObject> object,
int index,
- Map* transition,
+ Handle<Map> transition,
Register receiver_reg,
Register name_reg,
Register scratch,
@@ -793,12 +793,12 @@
ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded());
// Perform map transition for the receiver if necessary.
- if ((transition != NULL) && (object->map()->unused_property_fields() ==
0)) {
+ if (!transition.is_null() && (object->map()->unused_property_fields() ==
0)) {
// The properties must be extended before we can store the value.
// We jump to a runtime call that extends the properties array.
__ pop(scratch); // Return address.
__ push(receiver_reg);
- __ Push(Handle<Map>(transition));
+ __ Push(transition);
__ push(rax);
__ push(scratch);
__ TailCallExternalReference(
@@ -809,11 +809,10 @@
return;
}
- if (transition != NULL) {
+ if (!transition.is_null()) {
// Update the map of the object; no write barrier updating is
// needed because the map is never in new space.
- __ Move(FieldOperand(receiver_reg, HeapObject::kMapOffset),
- Handle<Map>(transition));
+ __ Move(FieldOperand(receiver_reg, HeapObject::kMapOffset),
transition);
}
// Adjust for the number of properties stored in the object. Even in the
@@ -2569,10 +2568,10 @@
}
-MaybeObject* StoreStubCompiler::CompileStoreField(JSObject* object,
+Handle<Code> StoreStubCompiler::CompileStoreField(Handle<JSObject> object,
int index,
- Map* transition,
- String* name) {
+ Handle<Map> transition,
+ Handle<String> name) {
// ----------- S t a t e -------------
// -- rax : value
// -- rcx : name
@@ -2582,12 +2581,7 @@
Label miss;
// Generate store field code. Preserves receiver and name on jump to
miss.
- GenerateStoreField(masm(),
- object,
- index,
- transition,
- rdx, rcx, rbx,
- &miss);
+ GenerateStoreField(masm(), object, index, transition, rdx, rcx, rbx,
&miss);
// Handle store cache miss.
__ bind(&miss);
@@ -2595,7 +2589,7 @@
__ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name);
+ return GetCode(transition.is_null() ? FIELD : MAP_TRANSITION, name);
}
@@ -2645,7 +2639,7 @@
__ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(CALLBACKS, name);
+ return TryGetCode(CALLBACKS, name);
}
@@ -2694,13 +2688,14 @@
__ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(INTERCEPTOR, name);
+ return TryGetCode(INTERCEPTOR, name);
}
-MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object,
- JSGlobalPropertyCell*
cell,
- String* name) {
+Handle<Code> StoreStubCompiler::CompileStoreGlobal(
+ Handle<GlobalObject> object,
+ Handle<JSGlobalPropertyCell> cell,
+ Handle<String> name) {
// ----------- S t a t e -------------
// -- rax : value
// -- rcx : name
@@ -2715,7 +2710,7 @@
__ j(not_equal, &miss);
// Compute the cell operand to use.
- __ Move(rbx, Handle<JSGlobalPropertyCell>(cell));
+ __ Move(rbx, cell);
Operand cell_operand = FieldOperand(rbx,
JSGlobalPropertyCell::kValueOffset);
// Check that the value in the cell is not the hole. If it is, this
@@ -2759,10 +2754,10 @@
}
-MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
+Handle<Code> KeyedStoreStubCompiler::CompileStoreField(Handle<JSObject>
object,
int index,
- Map* transition,
- String* name) {
+ Handle<Map>
transition,
+ Handle<String>
name) {
// ----------- S t a t e -------------
// -- rax : value
// -- rcx : key
@@ -2775,16 +2770,11 @@
__ IncrementCounter(counters->keyed_store_field(), 1);
// Check that the name has not changed.
- __ Cmp(rcx, Handle<String>(name));
+ __ Cmp(rcx, name);
__ j(not_equal, &miss);
// Generate store field code. Preserves receiver and name on jump to
miss.
- GenerateStoreField(masm(),
- object,
- index,
- transition,
- rdx, rcx, rbx,
- &miss);
+ GenerateStoreField(masm(), object, index, transition, rdx, rcx, rbx,
&miss);
// Handle store cache miss.
__ bind(&miss);
@@ -2793,40 +2783,38 @@
__ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name);
+ return GetCode(transition.is_null() ? FIELD : MAP_TRANSITION, name);
}
-MaybeObject* KeyedStoreStubCompiler::CompileStoreElement(Map*
receiver_map) {
+Handle<Code> KeyedStoreStubCompiler::CompileStoreElement(
+ Handle<Map> receiver_map) {
// ----------- S t a t e -------------
// -- rax : value
// -- rcx : key
// -- rdx : receiver
// -- rsp[0] : return address
// -----------------------------------
- Code* stub;
+
ElementsKind elements_kind = receiver_map->elements_kind();
bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
- MaybeObject* maybe_stub =
- KeyedStoreElementStub(is_js_array, elements_kind).TryGetCode();
- if (!maybe_stub->To(&stub)) return maybe_stub;
- __ DispatchMap(rdx,
- Handle<Map>(receiver_map),
- Handle<Code>(stub),
- DO_SMI_CHECK);
+ Handle<Code> stub =
+ KeyedStoreElementStub(is_js_array, elements_kind).GetCode();
+
+ __ DispatchMap(rdx, receiver_map, stub, DO_SMI_CHECK);
Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
__ jmp(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(NORMAL, NULL);
+ return GetCode(NORMAL, factory()->empty_string());
}
-MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic(
- MapList* receiver_maps,
- CodeList* handler_stubs,
- MapList* transitioned_maps) {
+Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
+ MapHandleList* receiver_maps,
+ CodeHandleList* handler_stubs,
+ MapHandleList* transitioned_maps) {
// ----------- S t a t e -------------
// -- rax : value
// -- rcx : key
@@ -2840,17 +2828,14 @@
int receiver_count = receiver_maps->length();
for (int i = 0; i < receiver_count; ++i) {
// Check map and tail call if there's a match
- Handle<Map> map(receiver_maps->at(i));
- __ Cmp(rdi, map);
- if (transitioned_maps->at(i) == NULL) {
- __ j(equal, Handle<Code>(handler_stubs->at(i)),
RelocInfo::CODE_TARGET);
+ __ Cmp(rdi, receiver_maps->at(i));
+ if (transitioned_maps->at(i).is_null()) {
+ __ j(equal, handler_stubs->at(i), RelocInfo::CODE_TARGET);
} else {
Label next_map;
__ j(not_equal, &next_map, Label::kNear);
- __ movq(rbx,
- Handle<Map>(transitioned_maps->at(i)),
- RelocInfo::EMBEDDED_OBJECT);
- __ jmp(Handle<Code>(handler_stubs->at(i)), RelocInfo::CODE_TARGET);
+ __ movq(rbx, transitioned_maps->at(i), RelocInfo::EMBEDDED_OBJECT);
+ __ jmp(handler_stubs->at(i), RelocInfo::CODE_TARGET);
__ bind(&next_map);
}
}
@@ -2860,7 +2845,7 @@
__ jmp(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(NORMAL, NULL, MEGAMORPHIC);
+ return GetCode(NORMAL, factory()->empty_string(), MEGAMORPHIC);
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev