Commit d3da21b5 authored by akos.palfi@imgtec.com's avatar akos.palfi@imgtec.com

MIPS: Restructure the IC / Handler compilers

Port r22622 (319e3252)

BUG=
R=paul.lind@imgtec.com

Review URL: https://codereview.chromium.org/414303003

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22626 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 85cee45e
......@@ -1939,20 +1939,11 @@ void InstanceofStub::Generate(MacroAssembler* masm) {
void FunctionPrototypeStub::Generate(MacroAssembler* masm) {
Label miss;
Register receiver = LoadIC::ReceiverRegister();
Register name = LoadIC::NameRegister();
ASSERT(kind() == Code::LOAD_IC ||
kind() == Code::KEYED_LOAD_IC);
if (kind() == Code::KEYED_LOAD_IC) {
__ Branch(&miss, ne, name,
Operand(isolate()->factory()->prototype_string()));
}
StubCompiler::GenerateLoadFunctionPrototype(masm, receiver, a3, t0, &miss);
NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(masm, receiver, a3,
t0, &miss);
__ bind(&miss);
StubCompiler::TailCallBuiltin(
masm, BaseLoadStoreStubCompiler::MissBuiltin(kind()));
PropertyAccessCompiler::TailCallBuiltin(
masm, PropertyAccessCompiler::MissBuiltin(Code::LOAD_IC));
}
......
......@@ -94,12 +94,9 @@ static void ProbeTable(Isolate* isolate,
}
void StubCompiler::GenerateDictionaryNegativeLookup(MacroAssembler* masm,
Label* miss_label,
Register receiver,
Handle<Name> name,
Register scratch0,
Register scratch1) {
void PropertyHandlerCompiler::GenerateDictionaryNegativeLookup(
MacroAssembler* masm, Label* miss_label, Register receiver,
Handle<Name> name, Register scratch0, Register scratch1) {
ASSERT(name->IsUniqueName());
ASSERT(!receiver.is(scratch0));
Counters* counters = masm->isolate()->counters();
......@@ -239,30 +236,8 @@ void StubCache::GenerateProbe(MacroAssembler* masm,
}
void StubCompiler::GenerateLoadGlobalFunctionPrototype(MacroAssembler* masm,
int index,
Register prototype) {
// Load the global or builtins object from the current context.
__ lw(prototype,
MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)));
// Load the native context from the global or builtins object.
__ lw(prototype,
FieldMemOperand(prototype, GlobalObject::kNativeContextOffset));
// Load the function from the native context.
__ lw(prototype, MemOperand(prototype, Context::SlotOffset(index)));
// Load the initial map. The global functions all have initial maps.
__ lw(prototype,
FieldMemOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset));
// Load the prototype from the initial map.
__ lw(prototype, FieldMemOperand(prototype, Map::kPrototypeOffset));
}
void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype(
MacroAssembler* masm,
int index,
Register prototype,
Label* miss) {
void NamedLoadHandlerCompiler::GenerateDirectLoadGlobalFunctionPrototype(
MacroAssembler* masm, int index, Register prototype, Label* miss) {
Isolate* isolate = masm->isolate();
// Get the global function with the given index.
Handle<JSFunction> function(
......@@ -284,57 +259,18 @@ void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype(
}
void StubCompiler::GenerateFastPropertyLoad(MacroAssembler* masm,
Register dst,
Register src,
bool inobject,
int index,
Representation representation) {
ASSERT(!representation.IsDouble());
int offset = index * kPointerSize;
if (!inobject) {
// Calculate the offset into the properties array.
offset = offset + FixedArray::kHeaderSize;
__ lw(dst, FieldMemOperand(src, JSObject::kPropertiesOffset));
src = dst;
}
__ lw(dst, FieldMemOperand(src, offset));
}
void StubCompiler::GenerateLoadArrayLength(MacroAssembler* masm,
Register receiver,
Register scratch,
Label* miss_label) {
// Check that the receiver isn't a smi.
__ JumpIfSmi(receiver, miss_label);
// Check that the object is a JS array.
__ GetObjectType(receiver, scratch, scratch);
__ Branch(miss_label, ne, scratch, Operand(JS_ARRAY_TYPE));
// Load length directly from the JS array.
__ Ret(USE_DELAY_SLOT);
__ lw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset));
}
void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm,
Register receiver,
Register scratch1,
Register scratch2,
Label* miss_label) {
void NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(
MacroAssembler* masm, Register receiver, Register scratch1,
Register scratch2, Label* miss_label) {
__ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label);
__ Ret(USE_DELAY_SLOT);
__ mov(v0, scratch1);
}
void StubCompiler::GenerateCheckPropertyCell(MacroAssembler* masm,
Handle<JSGlobalObject> global,
Handle<Name> name,
Register scratch,
Label* miss) {
void PropertyHandlerCompiler::GenerateCheckPropertyCell(
MacroAssembler* masm, Handle<JSGlobalObject> global, Handle<Name> name,
Register scratch, Label* miss) {
Handle<Cell> cell = JSGlobalObject::EnsurePropertyCell(global, name);
ASSERT(cell->value()->IsTheHole());
__ li(scratch, Operand(cell));
......@@ -344,12 +280,9 @@ void StubCompiler::GenerateCheckPropertyCell(MacroAssembler* masm,
}
void StoreStubCompiler::GenerateNegativeHolderLookup(
MacroAssembler* masm,
Handle<JSObject> holder,
Register holder_reg,
Handle<Name> name,
Label* miss) {
void NamedStoreHandlerCompiler::GenerateNegativeHolderLookup(
MacroAssembler* masm, Handle<JSObject> holder, Register holder_reg,
Handle<Name> name, Label* miss) {
if (holder->IsJSGlobalObject()) {
GenerateCheckPropertyCell(
masm, Handle<JSGlobalObject>::cast(holder), name, scratch1(), miss);
......@@ -363,19 +296,11 @@ void StoreStubCompiler::GenerateNegativeHolderLookup(
// Generate StoreTransition code, value is passed in a0 register.
// After executing generated code, the receiver_reg and name_reg
// may be clobbered.
void StoreStubCompiler::GenerateStoreTransition(MacroAssembler* masm,
Handle<JSObject> object,
LookupResult* lookup,
Handle<Map> transition,
Handle<Name> name,
Register receiver_reg,
Register storage_reg,
Register value_reg,
Register scratch1,
Register scratch2,
Register scratch3,
Label* miss_label,
Label* slow) {
void NamedStoreHandlerCompiler::GenerateStoreTransition(
MacroAssembler* masm, Handle<JSObject> object, LookupResult* lookup,
Handle<Map> transition, Handle<Name> name, Register receiver_reg,
Register storage_reg, Register value_reg, Register scratch1,
Register scratch2, Register scratch3, Label* miss_label, Label* slow) {
// a0 : value.
Label exit;
......@@ -546,15 +471,10 @@ void StoreStubCompiler::GenerateStoreTransition(MacroAssembler* masm,
// When leaving generated code after success, the receiver_reg and name_reg
// may be clobbered. Upon branch to miss_label, the receiver and name
// registers have their original values.
void StoreStubCompiler::GenerateStoreField(MacroAssembler* masm,
Handle<JSObject> object,
LookupResult* lookup,
Register receiver_reg,
Register name_reg,
Register value_reg,
Register scratch1,
Register scratch2,
Label* miss_label) {
void NamedStoreHandlerCompiler::GenerateStoreField(
MacroAssembler* masm, Handle<JSObject> object, LookupResult* lookup,
Register receiver_reg, Register name_reg, Register value_reg,
Register scratch1, Register scratch2, Label* miss_label) {
// a0 : value
Label exit;
......@@ -676,7 +596,7 @@ void StoreStubCompiler::GenerateStoreField(MacroAssembler* masm,
}
void StoreStubCompiler::GenerateRestoreName(MacroAssembler* masm,
void NamedStoreHandlerCompiler::GenerateRestoreName(MacroAssembler* masm,
Label* label,
Handle<Name> name) {
if (!label->is_unused()) {
......@@ -720,14 +640,10 @@ static void CompileCallLoadPropertyWithInterceptor(
// Generate call to api function.
void StubCompiler::GenerateFastApiCall(MacroAssembler* masm,
const CallOptimization& optimization,
Handle<Map> receiver_map,
Register receiver,
Register scratch_in,
bool is_store,
int argc,
Register* values) {
void PropertyHandlerCompiler::GenerateFastApiCall(
MacroAssembler* masm, const CallOptimization& optimization,
Handle<Map> receiver_map, Register receiver, Register scratch_in,
bool is_store, int argc, Register* values) {
ASSERT(!receiver.is(scratch_in));
// Preparing to push, adjust sp.
__ Subu(sp, sp, Operand((argc + 1) * kPointerSize));
......@@ -799,7 +715,8 @@ void StubCompiler::GenerateFastApiCall(MacroAssembler* masm,
}
void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) {
void PropertyAccessCompiler::GenerateTailCall(MacroAssembler* masm,
Handle<Code> code) {
__ Jump(code, RelocInfo::CODE_TARGET);
}
......@@ -808,15 +725,10 @@ void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) {
#define __ ACCESS_MASM(masm())
Register StubCompiler::CheckPrototypes(Handle<HeapType> type,
Register object_reg,
Handle<JSObject> holder,
Register holder_reg,
Register scratch1,
Register scratch2,
Handle<Name> name,
Label* miss,
PrototypeCheckType check) {
Register PropertyHandlerCompiler::CheckPrototypes(
Handle<HeapType> type, Register object_reg, Handle<JSObject> holder,
Register holder_reg, Register scratch1, Register scratch2,
Handle<Name> name, Label* miss, PrototypeCheckType check) {
Handle<Map> receiver_map(IC::TypeToMap(*type, isolate()));
// Make sure there's no overlap between holder and object registers.
......@@ -923,7 +835,7 @@ Register StubCompiler::CheckPrototypes(Handle<HeapType> type,
}
void LoadStubCompiler::HandlerFrontendFooter(Handle<Name> name, Label* miss) {
void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
if (!miss->is_unused()) {
Label success;
__ Branch(&success);
......@@ -934,7 +846,7 @@ void LoadStubCompiler::HandlerFrontendFooter(Handle<Name> name, Label* miss) {
}
void StoreStubCompiler::HandlerFrontendFooter(Handle<Name> name, Label* miss) {
void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
if (!miss->is_unused()) {
Label success;
__ Branch(&success);
......@@ -945,15 +857,14 @@ void StoreStubCompiler::HandlerFrontendFooter(Handle<Name> name, Label* miss) {
}
Register LoadStubCompiler::CallbackHandlerFrontend(
Handle<HeapType> type,
Register NamedLoadHandlerCompiler::CallbackFrontend(Handle<HeapType> type,
Register object_reg,
Handle<JSObject> holder,
Handle<Name> name,
Handle<Object> callback) {
Label miss;
Register reg = HandlerFrontendHeader(type, object_reg, holder, name, &miss);
Register reg = FrontendHeader(type, object_reg, holder, name, &miss);
if (!holder->HasFastProperties() && !holder->IsJSGlobalObject()) {
ASSERT(!reg.is(scratch2()));
......@@ -985,14 +896,13 @@ Register LoadStubCompiler::CallbackHandlerFrontend(
__ Branch(&miss, ne, scratch2(), Operand(callback));
}
HandlerFrontendFooter(name, &miss);
FrontendFooter(name, &miss);
return reg;
}
void LoadStubCompiler::GenerateLoadField(Register reg,
Handle<JSObject> holder,
FieldIndex field,
void NamedLoadHandlerCompiler::GenerateLoadField(
Register reg, Handle<JSObject> holder, FieldIndex field,
Representation representation) {
if (!reg.is(receiver())) __ mov(receiver(), reg);
LoadFieldStub stub(isolate(), field);
......@@ -1000,16 +910,15 @@ void LoadStubCompiler::GenerateLoadField(Register reg,
}
void LoadStubCompiler::GenerateLoadConstant(Handle<Object> value) {
void NamedLoadHandlerCompiler::GenerateLoadConstant(Handle<Object> value) {
// Return the constant value.
__ li(v0, value);
__ Ret();
}
void LoadStubCompiler::GenerateLoadCallback(
Register reg,
Handle<ExecutableAccessorInfo> callback) {
void NamedLoadHandlerCompiler::GenerateLoadCallback(
Register reg, Handle<ExecutableAccessorInfo> callback) {
// Build AccessorInfo::args_ list on the stack and push property name below
// the exit frame to make GC aware of them and store pointers to them.
STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0);
......@@ -1057,11 +966,9 @@ void LoadStubCompiler::GenerateLoadCallback(
}
void LoadStubCompiler::GenerateLoadInterceptor(
Register holder_reg,
Handle<Object> object,
Handle<JSObject> interceptor_holder,
LookupResult* lookup,
void NamedLoadHandlerCompiler::GenerateLoadInterceptor(
Register holder_reg, Handle<Object> object,
Handle<JSObject> interceptor_holder, LookupResult* lookup,
Handle<Name> name) {
ASSERT(interceptor_holder->HasNamedInterceptor());
ASSERT(!interceptor_holder->GetNamedInterceptor()->getter()->IsUndefined());
......@@ -1142,13 +1049,11 @@ void LoadStubCompiler::GenerateLoadInterceptor(
}
Handle<Code> StoreStubCompiler::CompileStoreCallback(
Handle<JSObject> object,
Handle<JSObject> holder,
Handle<Name> name,
Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback(
Handle<JSObject> object, Handle<JSObject> holder, Handle<Name> name,
Handle<ExecutableAccessorInfo> callback) {
Register holder_reg = HandlerFrontend(
IC::CurrentTypeOf(object, isolate()), receiver(), holder, name);
Register holder_reg =
Frontend(IC::CurrentTypeOf(object, isolate()), receiver(), holder, name);
// Stub never generated for non-global objects that require access
// checks.
......@@ -1174,10 +1079,8 @@ Handle<Code> StoreStubCompiler::CompileStoreCallback(
#define __ ACCESS_MASM(masm)
void StoreStubCompiler::GenerateStoreViaSetter(
MacroAssembler* masm,
Handle<HeapType> type,
Register receiver,
void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
MacroAssembler* masm, Handle<HeapType> type, Register receiver,
Handle<JSFunction> setter) {
// ----------- S t a t e -------------
// -- ra : return address
......@@ -1220,9 +1123,8 @@ void StoreStubCompiler::GenerateStoreViaSetter(
#define __ ACCESS_MASM(masm())
Handle<Code> StoreStubCompiler::CompileStoreInterceptor(
Handle<JSObject> object,
Handle<Name> name) {
Handle<Code> NamedStoreHandlerCompiler::CompileStoreInterceptor(
Handle<JSObject> object, Handle<Name> name) {
__ Push(receiver(), this->name(), value());
// Do tail-call to the runtime system.
......@@ -1235,10 +1137,9 @@ Handle<Code> StoreStubCompiler::CompileStoreInterceptor(
}
Handle<Code> LoadStubCompiler::CompileLoadNonexistent(Handle<HeapType> type,
Handle<JSObject> last,
Handle<Name> name) {
NonexistentHandlerFrontend(type, last, name);
Handle<Code> NamedLoadHandlerCompiler::CompileLoadNonexistent(
Handle<HeapType> type, Handle<JSObject> last, Handle<Name> name) {
NonexistentFrontend(type, last, name);
// Return undefined if maps of the full prototype chain is still the same.
__ LoadRoot(v0, Heap::kUndefinedValueRootIndex);
......@@ -1249,7 +1150,7 @@ Handle<Code> LoadStubCompiler::CompileLoadNonexistent(Handle<HeapType> type,
}
Register* LoadStubCompiler::registers() {
Register* PropertyAccessCompiler::load_calling_convention() {
// receiver, name, scratch1, scratch2, scratch3, scratch4.
Register receiver = LoadIC::ReceiverRegister();
Register name = LoadIC::NameRegister();
......@@ -1258,21 +1159,7 @@ Register* LoadStubCompiler::registers() {
}
Register* KeyedLoadStubCompiler::registers() {
// receiver, name, scratch1, scratch2, scratch3, scratch4.
Register receiver = LoadIC::ReceiverRegister();
Register name = LoadIC::NameRegister();
static Register registers[] = { receiver, name, a3, a0, t0, t1 };
return registers;
}
Register StoreStubCompiler::value() {
return StoreIC::ValueRegister();
}
Register* StoreStubCompiler::registers() {
Register* PropertyAccessCompiler::store_calling_convention() {
// receiver, name, scratch1, scratch2, scratch3.
Register receiver = StoreIC::ReceiverRegister();
Register name = StoreIC::NameRegister();
......@@ -1281,7 +1168,7 @@ Register* StoreStubCompiler::registers() {
}
Register* KeyedStoreStubCompiler::registers() {
Register* PropertyAccessCompiler::keyed_store_calling_convention() {
// receiver, name, scratch1/map, scratch2, scratch3.
Register receiver = KeyedStoreIC::ReceiverRegister();
Register name = KeyedStoreIC::NameRegister();
......@@ -1291,13 +1178,15 @@ Register* KeyedStoreStubCompiler::registers() {
}
Register NamedStoreHandlerCompiler::value() { return StoreIC::ValueRegister(); }
#undef __
#define __ ACCESS_MASM(masm)
void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm,
Handle<HeapType> type,
Register receiver,
void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
MacroAssembler* masm, Handle<HeapType> type, Register receiver,
Handle<JSFunction> getter) {
// ----------- S t a t e -------------
// -- a0 : receiver
......@@ -1336,15 +1225,12 @@ void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm,
#define __ ACCESS_MASM(masm())
Handle<Code> LoadStubCompiler::CompileLoadGlobal(
Handle<HeapType> type,
Handle<GlobalObject> global,
Handle<PropertyCell> cell,
Handle<Name> name,
bool is_dont_delete) {
Handle<Code> NamedLoadHandlerCompiler::CompileLoadGlobal(
Handle<HeapType> type, Handle<GlobalObject> global,
Handle<PropertyCell> cell, Handle<Name> name, bool is_dont_delete) {
Label miss;
HandlerFrontendHeader(type, receiver(), global, name, &miss);
FrontendHeader(type, receiver(), global, name, &miss);
// Get the value from the cell.
__ li(a3, Operand(cell));
......@@ -1361,15 +1247,14 @@ Handle<Code> LoadStubCompiler::CompileLoadGlobal(
__ Ret(USE_DELAY_SLOT);
__ mov(v0, t0);
HandlerFrontendFooter(name, &miss);
FrontendFooter(name, &miss);
// Return the generated code.
return GetCode(kind(), Code::NORMAL, name);
}
Handle<Code> BaseLoadStoreStubCompiler::CompilePolymorphicIC(
TypeHandleList* types,
Handle<Code> PropertyICCompiler::CompilePolymorphic(TypeHandleList* types,
CodeHandleList* handlers,
Handle<Name> name,
Code::StubType type,
......@@ -1418,11 +1303,11 @@ Handle<Code> BaseLoadStoreStubCompiler::CompilePolymorphicIC(
// Return the generated code.
InlineCacheState state =
number_of_handled_maps > 1 ? POLYMORPHIC : MONOMORPHIC;
return GetICCode(kind(), type, name, state);
return GetCode(kind(), type, name, state);
}
void StoreStubCompiler::GenerateStoreArrayLength() {
void NamedStoreHandlerCompiler::GenerateStoreArrayLength() {
// Prepare tail call to StoreIC_ArrayLength.
__ Push(receiver(), value());
......@@ -1433,9 +1318,8 @@ void StoreStubCompiler::GenerateStoreArrayLength() {
}
Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
MapHandleList* receiver_maps,
CodeHandleList* handler_stubs,
Handle<Code> PropertyICCompiler::CompileIndexedStorePolymorphic(
MapHandleList* receiver_maps, CodeHandleList* handler_stubs,
MapHandleList* transitioned_maps) {
Label miss;
__ JumpIfSmi(receiver(), &miss);
......@@ -1459,8 +1343,7 @@ Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
TailCallBuiltin(masm(), MissBuiltin(kind()));
// Return the generated code.
return GetICCode(
kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
return GetCode(kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
}
......@@ -1468,7 +1351,7 @@ Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
#define __ ACCESS_MASM(masm)
void KeyedLoadStubCompiler::GenerateLoadDictionaryElement(
void IndexedHandlerCompiler::GenerateLoadDictionaryElement(
MacroAssembler* masm) {
// The return address is in ra.
Label slow, miss;
......
......@@ -1938,20 +1938,11 @@ void InstanceofStub::Generate(MacroAssembler* masm) {
void FunctionPrototypeStub::Generate(MacroAssembler* masm) {
Label miss;
Register receiver = LoadIC::ReceiverRegister();
Register name = LoadIC::NameRegister();
ASSERT(kind() == Code::LOAD_IC ||
kind() == Code::KEYED_LOAD_IC);
if (kind() == Code::KEYED_LOAD_IC) {
__ Branch(&miss, ne, name,
Operand(isolate()->factory()->prototype_string()));
}
StubCompiler::GenerateLoadFunctionPrototype(masm, receiver, a3, a4, &miss);
NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(masm, receiver, a3,
a4, &miss);
__ bind(&miss);
StubCompiler::TailCallBuiltin(
masm, BaseLoadStoreStubCompiler::MissBuiltin(kind()));
PropertyAccessCompiler::TailCallBuiltin(
masm, PropertyAccessCompiler::MissBuiltin(Code::LOAD_IC));
}
......
......@@ -94,12 +94,9 @@ static void ProbeTable(Isolate* isolate,
}
void StubCompiler::GenerateDictionaryNegativeLookup(MacroAssembler* masm,
Label* miss_label,
Register receiver,
Handle<Name> name,
Register scratch0,
Register scratch1) {
void PropertyHandlerCompiler::GenerateDictionaryNegativeLookup(
MacroAssembler* masm, Label* miss_label, Register receiver,
Handle<Name> name, Register scratch0, Register scratch1) {
ASSERT(name->IsUniqueName());
ASSERT(!receiver.is(scratch0));
Counters* counters = masm->isolate()->counters();
......@@ -240,30 +237,8 @@ void StubCache::GenerateProbe(MacroAssembler* masm,
}
void StubCompiler::GenerateLoadGlobalFunctionPrototype(MacroAssembler* masm,
int index,
Register prototype) {
// Load the global or builtins object from the current context.
__ ld(prototype,
MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)));
// Load the native context from the global or builtins object.
__ ld(prototype,
FieldMemOperand(prototype, GlobalObject::kNativeContextOffset));
// Load the function from the native context.
__ ld(prototype, MemOperand(prototype, Context::SlotOffset(index)));
// Load the initial map. The global functions all have initial maps.
__ ld(prototype,
FieldMemOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset));
// Load the prototype from the initial map.
__ ld(prototype, FieldMemOperand(prototype, Map::kPrototypeOffset));
}
void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype(
MacroAssembler* masm,
int index,
Register prototype,
Label* miss) {
void NamedLoadHandlerCompiler::GenerateDirectLoadGlobalFunctionPrototype(
MacroAssembler* masm, int index, Register prototype, Label* miss) {
Isolate* isolate = masm->isolate();
// Get the global function with the given index.
Handle<JSFunction> function(
......@@ -285,57 +260,18 @@ void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype(
}
void StubCompiler::GenerateFastPropertyLoad(MacroAssembler* masm,
Register dst,
Register src,
bool inobject,
int index,
Representation representation) {
ASSERT(!representation.IsDouble());
int offset = index * kPointerSize;
if (!inobject) {
// Calculate the offset into the properties array.
offset = offset + FixedArray::kHeaderSize;
__ ld(dst, FieldMemOperand(src, JSObject::kPropertiesOffset));
src = dst;
}
__ ld(dst, FieldMemOperand(src, offset));
}
void StubCompiler::GenerateLoadArrayLength(MacroAssembler* masm,
Register receiver,
Register scratch,
Label* miss_label) {
// Check that the receiver isn't a smi.
__ JumpIfSmi(receiver, miss_label);
// Check that the object is a JS array.
__ GetObjectType(receiver, scratch, scratch);
__ Branch(miss_label, ne, scratch, Operand(JS_ARRAY_TYPE));
// Load length directly from the JS array.
__ Ret(USE_DELAY_SLOT);
__ ld(v0, FieldMemOperand(receiver, JSArray::kLengthOffset));
}
void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm,
Register receiver,
Register scratch1,
Register scratch2,
Label* miss_label) {
void NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(
MacroAssembler* masm, Register receiver, Register scratch1,
Register scratch2, Label* miss_label) {
__ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label);
__ Ret(USE_DELAY_SLOT);
__ mov(v0, scratch1);
}
void StubCompiler::GenerateCheckPropertyCell(MacroAssembler* masm,
Handle<JSGlobalObject> global,
Handle<Name> name,
Register scratch,
Label* miss) {
void PropertyHandlerCompiler::GenerateCheckPropertyCell(
MacroAssembler* masm, Handle<JSGlobalObject> global, Handle<Name> name,
Register scratch, Label* miss) {
Handle<Cell> cell = JSGlobalObject::EnsurePropertyCell(global, name);
ASSERT(cell->value()->IsTheHole());
__ li(scratch, Operand(cell));
......@@ -345,12 +281,9 @@ void StubCompiler::GenerateCheckPropertyCell(MacroAssembler* masm,
}
void StoreStubCompiler::GenerateNegativeHolderLookup(
MacroAssembler* masm,
Handle<JSObject> holder,
Register holder_reg,
Handle<Name> name,
Label* miss) {
void NamedStoreHandlerCompiler::GenerateNegativeHolderLookup(
MacroAssembler* masm, Handle<JSObject> holder, Register holder_reg,
Handle<Name> name, Label* miss) {
if (holder->IsJSGlobalObject()) {
GenerateCheckPropertyCell(
masm, Handle<JSGlobalObject>::cast(holder), name, scratch1(), miss);
......@@ -364,19 +297,11 @@ void StoreStubCompiler::GenerateNegativeHolderLookup(
// Generate StoreTransition code, value is passed in a0 register.
// After executing generated code, the receiver_reg and name_reg
// may be clobbered.
void StoreStubCompiler::GenerateStoreTransition(MacroAssembler* masm,
Handle<JSObject> object,
LookupResult* lookup,
Handle<Map> transition,
Handle<Name> name,
Register receiver_reg,
Register storage_reg,
Register value_reg,
Register scratch1,
Register scratch2,
Register scratch3,
Label* miss_label,
Label* slow) {
void NamedStoreHandlerCompiler::GenerateStoreTransition(
MacroAssembler* masm, Handle<JSObject> object, LookupResult* lookup,
Handle<Map> transition, Handle<Name> name, Register receiver_reg,
Register storage_reg, Register value_reg, Register scratch1,
Register scratch2, Register scratch3, Label* miss_label, Label* slow) {
// a0 : value.
Label exit;
......@@ -547,15 +472,10 @@ void StoreStubCompiler::GenerateStoreTransition(MacroAssembler* masm,
// When leaving generated code after success, the receiver_reg and name_reg
// may be clobbered. Upon branch to miss_label, the receiver and name
// registers have their original values.
void StoreStubCompiler::GenerateStoreField(MacroAssembler* masm,
Handle<JSObject> object,
LookupResult* lookup,
Register receiver_reg,
Register name_reg,
Register value_reg,
Register scratch1,
Register scratch2,
Label* miss_label) {
void NamedStoreHandlerCompiler::GenerateStoreField(
MacroAssembler* masm, Handle<JSObject> object, LookupResult* lookup,
Register receiver_reg, Register name_reg, Register value_reg,
Register scratch1, Register scratch2, Label* miss_label) {
// a0 : value
Label exit;
......@@ -677,7 +597,7 @@ void StoreStubCompiler::GenerateStoreField(MacroAssembler* masm,
}
void StoreStubCompiler::GenerateRestoreName(MacroAssembler* masm,
void NamedStoreHandlerCompiler::GenerateRestoreName(MacroAssembler* masm,
Label* label,
Handle<Name> name) {
if (!label->is_unused()) {
......@@ -721,14 +641,10 @@ static void CompileCallLoadPropertyWithInterceptor(
// Generate call to api function.
void StubCompiler::GenerateFastApiCall(MacroAssembler* masm,
const CallOptimization& optimization,
Handle<Map> receiver_map,
Register receiver,
Register scratch_in,
bool is_store,
int argc,
Register* values) {
void PropertyHandlerCompiler::GenerateFastApiCall(
MacroAssembler* masm, const CallOptimization& optimization,
Handle<Map> receiver_map, Register receiver, Register scratch_in,
bool is_store, int argc, Register* values) {
ASSERT(!receiver.is(scratch_in));
// Preparing to push, adjust sp.
__ Dsubu(sp, sp, Operand((argc + 1) * kPointerSize));
......@@ -800,7 +716,8 @@ void StubCompiler::GenerateFastApiCall(MacroAssembler* masm,
}
void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) {
void PropertyAccessCompiler::GenerateTailCall(MacroAssembler* masm,
Handle<Code> code) {
__ Jump(code, RelocInfo::CODE_TARGET);
}
......@@ -809,15 +726,10 @@ void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) {
#define __ ACCESS_MASM(masm())
Register StubCompiler::CheckPrototypes(Handle<HeapType> type,
Register object_reg,
Handle<JSObject> holder,
Register holder_reg,
Register scratch1,
Register scratch2,
Handle<Name> name,
Label* miss,
PrototypeCheckType check) {
Register PropertyHandlerCompiler::CheckPrototypes(
Handle<HeapType> type, Register object_reg, Handle<JSObject> holder,
Register holder_reg, Register scratch1, Register scratch2,
Handle<Name> name, Label* miss, PrototypeCheckType check) {
Handle<Map> receiver_map(IC::TypeToMap(*type, isolate()));
// Make sure there's no overlap between holder and object registers.
......@@ -924,7 +836,7 @@ Register StubCompiler::CheckPrototypes(Handle<HeapType> type,
}
void LoadStubCompiler::HandlerFrontendFooter(Handle<Name> name, Label* miss) {
void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
if (!miss->is_unused()) {
Label success;
__ Branch(&success);
......@@ -935,7 +847,7 @@ void LoadStubCompiler::HandlerFrontendFooter(Handle<Name> name, Label* miss) {
}
void StoreStubCompiler::HandlerFrontendFooter(Handle<Name> name, Label* miss) {
void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
if (!miss->is_unused()) {
Label success;
__ Branch(&success);
......@@ -946,15 +858,14 @@ void StoreStubCompiler::HandlerFrontendFooter(Handle<Name> name, Label* miss) {
}
Register LoadStubCompiler::CallbackHandlerFrontend(
Handle<HeapType> type,
Register NamedLoadHandlerCompiler::CallbackFrontend(Handle<HeapType> type,
Register object_reg,
Handle<JSObject> holder,
Handle<Name> name,
Handle<Object> callback) {
Label miss;
Register reg = HandlerFrontendHeader(type, object_reg, holder, name, &miss);
Register reg = FrontendHeader(type, object_reg, holder, name, &miss);
if (!holder->HasFastProperties() && !holder->IsJSGlobalObject()) {
ASSERT(!reg.is(scratch2()));
......@@ -986,14 +897,13 @@ Register LoadStubCompiler::CallbackHandlerFrontend(
__ Branch(&miss, ne, scratch2(), Operand(callback));
}
HandlerFrontendFooter(name, &miss);
FrontendFooter(name, &miss);
return reg;
}
void LoadStubCompiler::GenerateLoadField(Register reg,
Handle<JSObject> holder,
FieldIndex field,
void NamedLoadHandlerCompiler::GenerateLoadField(
Register reg, Handle<JSObject> holder, FieldIndex field,
Representation representation) {
if (!reg.is(receiver())) __ mov(receiver(), reg);
LoadFieldStub stub(isolate(), field);
......@@ -1001,16 +911,15 @@ void LoadStubCompiler::GenerateLoadField(Register reg,
}
void LoadStubCompiler::GenerateLoadConstant(Handle<Object> value) {
void NamedLoadHandlerCompiler::GenerateLoadConstant(Handle<Object> value) {
// Return the constant value.
__ li(v0, value);
__ Ret();
}
void LoadStubCompiler::GenerateLoadCallback(
Register reg,
Handle<ExecutableAccessorInfo> callback) {
void NamedLoadHandlerCompiler::GenerateLoadCallback(
Register reg, Handle<ExecutableAccessorInfo> callback) {
// Build AccessorInfo::args_ list on the stack and push property name below
// the exit frame to make GC aware of them and store pointers to them.
STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0);
......@@ -1058,11 +967,9 @@ void LoadStubCompiler::GenerateLoadCallback(
}
void LoadStubCompiler::GenerateLoadInterceptor(
Register holder_reg,
Handle<Object> object,
Handle<JSObject> interceptor_holder,
LookupResult* lookup,
void NamedLoadHandlerCompiler::GenerateLoadInterceptor(
Register holder_reg, Handle<Object> object,
Handle<JSObject> interceptor_holder, LookupResult* lookup,
Handle<Name> name) {
ASSERT(interceptor_holder->HasNamedInterceptor());
ASSERT(!interceptor_holder->GetNamedInterceptor()->getter()->IsUndefined());
......@@ -1143,13 +1050,11 @@ void LoadStubCompiler::GenerateLoadInterceptor(
}
Handle<Code> StoreStubCompiler::CompileStoreCallback(
Handle<JSObject> object,
Handle<JSObject> holder,
Handle<Name> name,
Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback(
Handle<JSObject> object, Handle<JSObject> holder, Handle<Name> name,
Handle<ExecutableAccessorInfo> callback) {
Register holder_reg = HandlerFrontend(
IC::CurrentTypeOf(object, isolate()), receiver(), holder, name);
Register holder_reg =
Frontend(IC::CurrentTypeOf(object, isolate()), receiver(), holder, name);
// Stub never generated for non-global objects that require access
// checks.
......@@ -1175,10 +1080,8 @@ Handle<Code> StoreStubCompiler::CompileStoreCallback(
#define __ ACCESS_MASM(masm)
void StoreStubCompiler::GenerateStoreViaSetter(
MacroAssembler* masm,
Handle<HeapType> type,
Register receiver,
void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
MacroAssembler* masm, Handle<HeapType> type, Register receiver,
Handle<JSFunction> setter) {
// ----------- S t a t e -------------
// -- ra : return address
......@@ -1221,9 +1124,8 @@ void StoreStubCompiler::GenerateStoreViaSetter(
#define __ ACCESS_MASM(masm())
Handle<Code> StoreStubCompiler::CompileStoreInterceptor(
Handle<JSObject> object,
Handle<Name> name) {
Handle<Code> NamedStoreHandlerCompiler::CompileStoreInterceptor(
Handle<JSObject> object, Handle<Name> name) {
__ Push(receiver(), this->name(), value());
// Do tail-call to the runtime system.
......@@ -1236,10 +1138,9 @@ Handle<Code> StoreStubCompiler::CompileStoreInterceptor(
}
Handle<Code> LoadStubCompiler::CompileLoadNonexistent(Handle<HeapType> type,
Handle<JSObject> last,
Handle<Name> name) {
NonexistentHandlerFrontend(type, last, name);
Handle<Code> NamedLoadHandlerCompiler::CompileLoadNonexistent(
Handle<HeapType> type, Handle<JSObject> last, Handle<Name> name) {
NonexistentFrontend(type, last, name);
// Return undefined if maps of the full prototype chain is still the same.
__ LoadRoot(v0, Heap::kUndefinedValueRootIndex);
......@@ -1250,7 +1151,7 @@ Handle<Code> LoadStubCompiler::CompileLoadNonexistent(Handle<HeapType> type,
}
Register* LoadStubCompiler::registers() {
Register* PropertyAccessCompiler::load_calling_convention() {
// receiver, name, scratch1, scratch2, scratch3, scratch4.
Register receiver = LoadIC::ReceiverRegister();
Register name = LoadIC::NameRegister();
......@@ -1259,21 +1160,7 @@ Register* LoadStubCompiler::registers() {
}
Register* KeyedLoadStubCompiler::registers() {
// receiver, name, scratch1, scratch2, scratch3, scratch4.
Register receiver = LoadIC::ReceiverRegister();
Register name = LoadIC::NameRegister();
static Register registers[] = { receiver, name, a3, a0, a4, a5 };
return registers;
}
Register StoreStubCompiler::value() {
return StoreIC::ValueRegister();
}
Register* StoreStubCompiler::registers() {
Register* PropertyAccessCompiler::store_calling_convention() {
// receiver, name, scratch1, scratch2, scratch3.
Register receiver = StoreIC::ReceiverRegister();
Register name = StoreIC::NameRegister();
......@@ -1282,7 +1169,7 @@ Register* StoreStubCompiler::registers() {
}
Register* KeyedStoreStubCompiler::registers() {
Register* PropertyAccessCompiler::keyed_store_calling_convention() {
// receiver, name, scratch1/map, scratch2, scratch3.
Register receiver = KeyedStoreIC::ReceiverRegister();
Register name = KeyedStoreIC::NameRegister();
......@@ -1292,13 +1179,15 @@ Register* KeyedStoreStubCompiler::registers() {
}
Register NamedStoreHandlerCompiler::value() { return StoreIC::ValueRegister(); }
#undef __
#define __ ACCESS_MASM(masm)
void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm,
Handle<HeapType> type,
Register receiver,
void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
MacroAssembler* masm, Handle<HeapType> type, Register receiver,
Handle<JSFunction> getter) {
// ----------- S t a t e -------------
// -- a0 : receiver
......@@ -1337,15 +1226,12 @@ void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm,
#define __ ACCESS_MASM(masm())
Handle<Code> LoadStubCompiler::CompileLoadGlobal(
Handle<HeapType> type,
Handle<GlobalObject> global,
Handle<PropertyCell> cell,
Handle<Name> name,
bool is_dont_delete) {
Handle<Code> NamedLoadHandlerCompiler::CompileLoadGlobal(
Handle<HeapType> type, Handle<GlobalObject> global,
Handle<PropertyCell> cell, Handle<Name> name, bool is_dont_delete) {
Label miss;
HandlerFrontendHeader(type, receiver(), global, name, &miss);
FrontendHeader(type, receiver(), global, name, &miss);
// Get the value from the cell.
__ li(a3, Operand(cell));
......@@ -1362,15 +1248,14 @@ Handle<Code> LoadStubCompiler::CompileLoadGlobal(
__ Ret(USE_DELAY_SLOT);
__ mov(v0, a4);
HandlerFrontendFooter(name, &miss);
FrontendFooter(name, &miss);
// Return the generated code.
return GetCode(kind(), Code::NORMAL, name);
}
Handle<Code> BaseLoadStoreStubCompiler::CompilePolymorphicIC(
TypeHandleList* types,
Handle<Code> PropertyICCompiler::CompilePolymorphic(TypeHandleList* types,
CodeHandleList* handlers,
Handle<Name> name,
Code::StubType type,
......@@ -1419,11 +1304,11 @@ Handle<Code> BaseLoadStoreStubCompiler::CompilePolymorphicIC(
// Return the generated code.
InlineCacheState state =
number_of_handled_maps > 1 ? POLYMORPHIC : MONOMORPHIC;
return GetICCode(kind(), type, name, state);
return GetCode(kind(), type, name, state);
}
void StoreStubCompiler::GenerateStoreArrayLength() {
void NamedStoreHandlerCompiler::GenerateStoreArrayLength() {
// Prepare tail call to StoreIC_ArrayLength.
__ Push(receiver(), value());
......@@ -1434,9 +1319,8 @@ void StoreStubCompiler::GenerateStoreArrayLength() {
}
Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
MapHandleList* receiver_maps,
CodeHandleList* handler_stubs,
Handle<Code> PropertyICCompiler::CompileIndexedStorePolymorphic(
MapHandleList* receiver_maps, CodeHandleList* handler_stubs,
MapHandleList* transitioned_maps) {
Label miss;
__ JumpIfSmi(receiver(), &miss);
......@@ -1460,8 +1344,7 @@ Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
TailCallBuiltin(masm(), MissBuiltin(kind()));
// Return the generated code.
return GetICCode(
kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
return GetCode(kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
}
......@@ -1469,7 +1352,7 @@ Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
#define __ ACCESS_MASM(masm)
void KeyedLoadStubCompiler::GenerateLoadDictionaryElement(
void IndexedHandlerCompiler::GenerateLoadDictionaryElement(
MacroAssembler* masm) {
// The return address is in ra
Label slow, miss;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment