Handlify CompileLoadGlobal, CompileLoadElement, CompileLoadPolymorphic.

R=kmillikin@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/8375053

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9788 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
ulan@chromium.org 2011-10-26 09:58:32 +00:00
parent f7d56eb602
commit a2fff744e0
5 changed files with 65 additions and 128 deletions

View File

@ -3128,11 +3128,12 @@ MaybeObject* LoadStubCompiler::CompileLoadInterceptor(JSObject* object,
}
MaybeObject* LoadStubCompiler::CompileLoadGlobal(JSObject* object,
GlobalObject* holder,
JSGlobalPropertyCell* cell,
String* name,
bool is_dont_delete) {
Handle<Code> LoadStubCompiler::CompileLoadGlobal(
Handle<JSObject> object,
Handle<GlobalObject> holder,
Handle<JSGlobalPropertyCell> cell,
Handle<String> name,
bool is_dont_delete) {
// ----------- S t a t e -------------
// -- r0 : receiver
// -- r2 : name
@ -3143,7 +3144,7 @@ MaybeObject* LoadStubCompiler::CompileLoadGlobal(JSObject* object,
// If the object is the holder then we know that it's a global
// object which can only happen for contextual calls. In this case,
// the receiver cannot be a smi.
if (object != holder) {
if (!object.is_identical_to(holder)) {
__ JumpIfSmi(r0, &miss);
}
@ -3151,7 +3152,7 @@ MaybeObject* LoadStubCompiler::CompileLoadGlobal(JSObject* object,
CheckPrototypes(object, r0, holder, r3, r4, r1, name, &miss);
// Get the value from the cell.
__ mov(r3, Operand(Handle<JSGlobalPropertyCell>(cell)));
__ mov(r3, Operand(cell));
__ ldr(r4, FieldMemOperand(r3, JSGlobalPropertyCell::kValueOffset));
// Check for deleted property if property can actually be deleted.
@ -3171,7 +3172,7 @@ MaybeObject* LoadStubCompiler::CompileLoadGlobal(JSObject* object,
GenerateLoadMiss(masm(), Code::LOAD_IC);
// Return the generated code.
return TryGetCode(NORMAL, name);
return GetCode(NORMAL, name);
}
@ -3358,33 +3359,29 @@ Handle<Code> KeyedLoadStubCompiler::CompileLoadFunctionPrototype(
}
MaybeObject* KeyedLoadStubCompiler::CompileLoadElement(Map* receiver_map) {
Handle<Code> KeyedLoadStubCompiler::CompileLoadElement(
Handle<Map> receiver_map) {
// ----------- S t a t e -------------
// -- lr : return address
// -- r0 : key
// -- r1 : receiver
// -----------------------------------
Code* stub;
ElementsKind elements_kind = receiver_map->elements_kind();
MaybeObject* maybe_stub = KeyedLoadElementStub(elements_kind).TryGetCode();
if (!maybe_stub->To(&stub)) return maybe_stub;
__ DispatchMap(r1,
r2,
Handle<Map>(receiver_map),
Handle<Code>(stub),
DO_SMI_CHECK);
Handle<Code> stub = KeyedLoadElementStub(elements_kind).GetCode();
__ DispatchMap(r1, r2, receiver_map, stub, DO_SMI_CHECK);
Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Miss();
__ Jump(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
return TryGetCode(NORMAL, NULL);
return GetCode(NORMAL, factory()->empty_string());
}
MaybeObject* KeyedLoadStubCompiler::CompileLoadPolymorphic(
MapList* receiver_maps,
CodeList* handler_ics) {
Handle<Code> KeyedLoadStubCompiler::CompileLoadPolymorphic(
MapHandleList* receiver_maps,
CodeHandleList* handler_ics) {
// ----------- S t a t e -------------
// -- lr : return address
// -- r0 : key
@ -3396,11 +3393,9 @@ MaybeObject* KeyedLoadStubCompiler::CompileLoadPolymorphic(
int receiver_count = receiver_maps->length();
__ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset));
for (int current = 0; current < receiver_count; ++current) {
Handle<Map> map(receiver_maps->at(current));
Handle<Code> code(handler_ics->at(current));
__ mov(ip, Operand(map));
__ mov(ip, Operand(receiver_maps->at(current)));
__ cmp(r2, ip);
__ Jump(code, RelocInfo::CODE_TARGET, eq);
__ Jump(handler_ics->at(current), RelocInfo::CODE_TARGET, eq);
}
__ bind(&miss);
@ -3408,7 +3403,7 @@ MaybeObject* KeyedLoadStubCompiler::CompileLoadPolymorphic(
__ Jump(miss_ic, RelocInfo::CODE_TARGET, al);
// Return the generated code.
return TryGetCode(NORMAL, NULL, MEGAMORPHIC);
return GetCode(NORMAL, factory()->empty_string(), MEGAMORPHIC);
}

View File

@ -3130,11 +3130,12 @@ MaybeObject* LoadStubCompiler::CompileLoadInterceptor(JSObject* receiver,
}
MaybeObject* LoadStubCompiler::CompileLoadGlobal(JSObject* object,
GlobalObject* holder,
JSGlobalPropertyCell* cell,
String* name,
bool is_dont_delete) {
Handle<Code> LoadStubCompiler::CompileLoadGlobal(
Handle<JSObject> object,
Handle<GlobalObject> holder,
Handle<JSGlobalPropertyCell> cell,
Handle<String> name,
bool is_dont_delete) {
// ----------- S t a t e -------------
// -- eax : receiver
// -- ecx : name
@ -3145,7 +3146,7 @@ MaybeObject* LoadStubCompiler::CompileLoadGlobal(JSObject* object,
// If the object is the holder then we know that it's a global
// object which can only happen for contextual loads. In this case,
// the receiver cannot be a smi.
if (object != holder) {
if (!object.is_identical_to(holder)) {
__ JumpIfSmi(eax, &miss);
}
@ -3154,10 +3155,10 @@ MaybeObject* LoadStubCompiler::CompileLoadGlobal(JSObject* object,
// Get the value from the cell.
if (Serializer::enabled()) {
__ mov(ebx, Immediate(Handle<JSGlobalPropertyCell>(cell)));
__ mov(ebx, Immediate(cell));
__ mov(ebx, FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset));
} else {
__ mov(ebx, Operand::Cell(Handle<JSGlobalPropertyCell>(cell)));
__ mov(ebx, Operand::Cell(cell));
}
// Check for deleted property if property can actually be deleted.
@ -3179,7 +3180,7 @@ MaybeObject* LoadStubCompiler::CompileLoadGlobal(JSObject* object,
GenerateLoadMiss(masm(), Code::LOAD_IC);
// Return the generated code.
return TryGetCode(NORMAL, name);
return GetCode(NORMAL, name);
}
@ -3394,31 +3395,29 @@ Handle<Code> KeyedLoadStubCompiler::CompileLoadFunctionPrototype(
}
MaybeObject* KeyedLoadStubCompiler::CompileLoadElement(Map* receiver_map) {
Handle<Code> KeyedLoadStubCompiler::CompileLoadElement(
Handle<Map> receiver_map) {
// ----------- S t a t e -------------
// -- eax : key
// -- edx : receiver
// -- esp[0] : return address
// -----------------------------------
Code* stub;
ElementsKind elements_kind = receiver_map->elements_kind();
MaybeObject* maybe_stub = KeyedLoadElementStub(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 = KeyedLoadElementStub(elements_kind).GetCode();
__ DispatchMap(edx, receiver_map, stub, DO_SMI_CHECK);
GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
// Return the generated code.
return TryGetCode(NORMAL, NULL);
return GetCode(NORMAL, factory()->empty_string());
}
MaybeObject* KeyedLoadStubCompiler::CompileLoadPolymorphic(
MapList* receiver_maps,
CodeList* handler_ics) {
Handle<Code> KeyedLoadStubCompiler::CompileLoadPolymorphic(
MapHandleList* receiver_maps,
CodeHandleList* handler_ics) {
// ----------- S t a t e -------------
// -- eax : key
// -- edx : receiver
@ -3431,16 +3430,15 @@ MaybeObject* KeyedLoadStubCompiler::CompileLoadPolymorphic(
__ mov(map_reg, FieldOperand(edx, HeapObject::kMapOffset));
int receiver_count = receiver_maps->length();
for (int current = 0; current < receiver_count; ++current) {
Handle<Map> map(receiver_maps->at(current));
__ cmp(map_reg, map);
__ j(equal, Handle<Code>(handler_ics->at(current)));
__ cmp(map_reg, receiver_maps->at(current));
__ j(equal, handler_ics->at(current));
}
__ bind(&miss);
GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
// Return the generated code.
return TryGetCode(NORMAL, NULL, MEGAMORPHIC);
return GetCode(NORMAL, factory()->empty_string(), MEGAMORPHIC);
}

View File

@ -246,20 +246,6 @@ Handle<Code> StubCache::ComputeLoadNormal() {
}
Handle<Code> LoadStubCompiler::CompileLoadGlobal(
Handle<JSObject> object,
Handle<GlobalObject> holder,
Handle<JSGlobalPropertyCell> cell,
Handle<String> name,
bool is_dont_delete) {
CALL_HEAP_FUNCTION(isolate(),
(set_failure(NULL),
CompileLoadGlobal(
*object, *holder, *cell, *name, is_dont_delete)),
Code);
}
Handle<Code> StubCache::ComputeLoadGlobal(Handle<String> name,
Handle<JSObject> receiver,
Handle<GlobalObject> holder,
@ -466,13 +452,6 @@ Handle<Code> StubCache::ComputeStoreField(Handle<String> name,
}
Handle<Code> KeyedLoadStubCompiler::CompileLoadElement(Handle<Map> map) {
CALL_HEAP_FUNCTION(isolate(),
(set_failure(NULL), CompileLoadElement(*map)),
Code);
}
Handle<Code> KeyedStoreStubCompiler::CompileStoreElement(Handle<Map> map) {
CALL_HEAP_FUNCTION(isolate(),
(set_failure(NULL),
@ -536,24 +515,6 @@ Handle<Code> StubCache::ComputeKeyedLoadOrStoreElement(
}
Handle<Code> KeyedLoadStubCompiler::CompileLoadPolymorphic(
MapHandleList* receiver_maps,
CodeHandleList* handler_stubs) {
MapList raw_receiver_maps(receiver_maps->length());
CodeList raw_handler_stubs(handler_stubs->length());
CALL_HEAP_FUNCTION(
isolate(),
(set_failure(NULL),
raw_receiver_maps.Clear(),
raw_handler_stubs.Clear(),
CompileLoadPolymorphic(UnwrapHandleList(&raw_receiver_maps,
receiver_maps),
UnwrapHandleList(&raw_handler_stubs,
handler_stubs))),
Code);
}
Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
MapHandleList* receiver_maps,
CodeHandleList* handler_stubs,

View File

@ -627,12 +627,6 @@ class LoadStubCompiler: public StubCompiler {
Handle<String> name,
bool is_dont_delete);
MUST_USE_RESULT MaybeObject* CompileLoadGlobal(JSObject* object,
GlobalObject* holder,
JSGlobalPropertyCell* cell,
String* name,
bool is_dont_delete);
private:
MUST_USE_RESULT MaybeObject* TryGetCode(PropertyType type, String* name);
@ -680,15 +674,9 @@ class KeyedLoadStubCompiler: public StubCompiler {
Handle<Code> CompileLoadElement(Handle<Map> receiver_map);
MUST_USE_RESULT MaybeObject* CompileLoadElement(Map* receiver_map);
Handle<Code> CompileLoadPolymorphic(MapHandleList* receiver_maps,
CodeHandleList* handler_ics);
MUST_USE_RESULT MaybeObject* CompileLoadPolymorphic(
MapList* receiver_maps,
CodeList* handler_ics);
static void GenerateLoadExternalArray(MacroAssembler* masm,
ElementsKind elements_kind);

View File

@ -3002,11 +3002,12 @@ MaybeObject* LoadStubCompiler::CompileLoadInterceptor(JSObject* receiver,
}
MaybeObject* LoadStubCompiler::CompileLoadGlobal(JSObject* object,
GlobalObject* holder,
JSGlobalPropertyCell* cell,
String* name,
bool is_dont_delete) {
Handle<Code> LoadStubCompiler::CompileLoadGlobal(
Handle<JSObject> object,
Handle<GlobalObject> holder,
Handle<JSGlobalPropertyCell> cell,
Handle<String> name,
bool is_dont_delete) {
// ----------- S t a t e -------------
// -- rax : receiver
// -- rcx : name
@ -3017,7 +3018,7 @@ MaybeObject* LoadStubCompiler::CompileLoadGlobal(JSObject* object,
// If the object is the holder then we know that it's a global
// object which can only happen for contextual loads. In this case,
// the receiver cannot be a smi.
if (object != holder) {
if (!object.is_identical_to(holder)) {
__ JumpIfSmi(rax, &miss);
}
@ -3025,7 +3026,7 @@ MaybeObject* LoadStubCompiler::CompileLoadGlobal(JSObject* object,
CheckPrototypes(object, rax, holder, rbx, rdx, rdi, name, &miss);
// Get the value from the cell.
__ Move(rbx, Handle<JSGlobalPropertyCell>(cell));
__ Move(rbx, cell);
__ movq(rbx, FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset));
// Check for deleted property if property can actually be deleted.
@ -3047,7 +3048,7 @@ MaybeObject* LoadStubCompiler::CompileLoadGlobal(JSObject* object,
GenerateLoadMiss(masm(), Code::LOAD_IC);
// Return the generated code.
return TryGetCode(NORMAL, name);
return GetCode(NORMAL, name);
}
@ -3262,32 +3263,29 @@ Handle<Code> KeyedLoadStubCompiler::CompileLoadFunctionPrototype(
}
MaybeObject* KeyedLoadStubCompiler::CompileLoadElement(Map* receiver_map) {
Handle<Code> KeyedLoadStubCompiler::CompileLoadElement(
Handle<Map> receiver_map) {
// ----------- S t a t e -------------
// -- rax : key
// -- rdx : receiver
// -- rsp[0] : return address
// -----------------------------------
Code* stub;
ElementsKind elements_kind = receiver_map->elements_kind();
MaybeObject* maybe_stub = KeyedLoadElementStub(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 = KeyedLoadElementStub(elements_kind).GetCode();
__ DispatchMap(rdx, receiver_map, stub, DO_SMI_CHECK);
Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Miss();
__ jmp(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
return TryGetCode(NORMAL, NULL);
return GetCode(NORMAL, factory()->empty_string());
}
MaybeObject* KeyedLoadStubCompiler::CompileLoadPolymorphic(
MapList* receiver_maps,
CodeList* handler_ics) {
Handle<Code> KeyedLoadStubCompiler::CompileLoadPolymorphic(
MapHandleList* receiver_maps,
CodeHandleList* handler_ics) {
// ----------- S t a t e -------------
// -- rax : key
// -- rdx : receiver
@ -3301,18 +3299,15 @@ MaybeObject* KeyedLoadStubCompiler::CompileLoadPolymorphic(
int receiver_count = receiver_maps->length();
for (int current = 0; current < receiver_count; ++current) {
// Check map and tail call if there's a match
Handle<Map> map(receiver_maps->at(current));
__ Cmp(map_reg, map);
__ j(equal,
Handle<Code>(handler_ics->at(current)),
RelocInfo::CODE_TARGET);
__ Cmp(map_reg, receiver_maps->at(current));
__ j(equal, handler_ics->at(current), RelocInfo::CODE_TARGET);
}
__ bind(&miss);
GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
// Return the generated code.
return TryGetCode(NORMAL, NULL, MEGAMORPHIC);
return GetCode(NORMAL, factory()->empty_string(), MEGAMORPHIC);
}