Commit 6953861e authored by verwaest@chromium.org's avatar verwaest@chromium.org

MIPS: Replace store array length builtin with codestub.

Port r13506 (0d666576)

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/12077009
Patch from Akos Palfi <palfia@homejinni.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13528 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8a86ce7e
......@@ -4633,6 +4633,76 @@ void StringLengthStub::Generate(MacroAssembler* masm) {
}
void StoreArrayLengthStub::Generate(MacroAssembler* masm) {
// This accepts as a receiver anything JSArray::SetElementsLength accepts
// (currently anything except for external arrays which means anything with
// elements of FixedArray type). Value must be a number, but only smis are
// accepted as the most common case.
Label miss;
Register receiver;
Register value;
if (kind() == Code::KEYED_STORE_IC) {
// ----------- S t a t e -------------
// -- ra : return address
// -- a0 : value
// -- a1 : key
// -- a2 : receiver
// -----------------------------------
__ Branch(&miss, ne, a1,
Operand(masm->isolate()->factory()->length_symbol()));
receiver = a2;
value = a0;
} else {
ASSERT(kind() == Code::STORE_IC);
// ----------- S t a t e -------------
// -- ra : return address
// -- a0 : value
// -- a1 : receiver
// -- a2 : key
// -----------------------------------
receiver = a1;
value = a0;
}
Register scratch = a3;
// Check that the receiver isn't a smi.
__ JumpIfSmi(receiver, &miss);
// Check that the object is a JS array.
__ GetObjectType(receiver, scratch, scratch);
__ Branch(&miss, ne, scratch, Operand(JS_ARRAY_TYPE));
// Check that elements are FixedArray.
// We rely on StoreIC_ArrayLength below to deal with all types of
// fast elements (including COW).
__ lw(scratch, FieldMemOperand(receiver, JSArray::kElementsOffset));
__ GetObjectType(scratch, scratch, scratch);
__ Branch(&miss, ne, scratch, Operand(FIXED_ARRAY_TYPE));
// Check that the array has fast properties, otherwise the length
// property might have been redefined.
__ lw(scratch, FieldMemOperand(receiver, JSArray::kPropertiesOffset));
__ lw(scratch, FieldMemOperand(scratch, FixedArray::kMapOffset));
__ LoadRoot(at, Heap::kHashTableMapRootIndex);
__ Branch(&miss, eq, scratch, Operand(at));
// Check that value is a smi.
__ JumpIfNotSmi(value, &miss);
// Prepare tail call to StoreIC_ArrayLength.
__ Push(receiver, value);
ExternalReference ref =
ExternalReference(IC_Utility(IC::kStoreIC_ArrayLength), masm->isolate());
__ TailCallExternalReference(ref, 2, 1);
__ bind(&miss);
StubCompiler::GenerateStoreMiss(masm, kind());
}
Register InstanceofStub::left() { return a0; }
......
......@@ -1535,62 +1535,6 @@ void StoreIC::GenerateMiss(MacroAssembler* masm) {
}
void StoreIC::GenerateArrayLength(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- a0 : value
// -- a1 : receiver
// -- a2 : name
// -- ra : return address
// -----------------------------------
//
// This accepts as a receiver anything JSArray::SetElementsLength accepts
// (currently anything except for external arrays which means anything with
// elements of FixedArray type). Value must be a number, but only smis are
// accepted as the most common case.
Label miss;
Register receiver = a1;
Register value = a0;
Register scratch = a3;
// Check that the receiver isn't a smi.
__ JumpIfSmi(receiver, &miss);
// Check that the object is a JS array.
__ GetObjectType(receiver, scratch, scratch);
__ Branch(&miss, ne, scratch, Operand(JS_ARRAY_TYPE));
// Check that elements are FixedArray.
// We rely on StoreIC_ArrayLength below to deal with all types of
// fast elements (including COW).
__ lw(scratch, FieldMemOperand(receiver, JSArray::kElementsOffset));
__ GetObjectType(scratch, scratch, scratch);
__ Branch(&miss, ne, scratch, Operand(FIXED_ARRAY_TYPE));
// Check that the array has fast properties, otherwise the length
// property might have been redefined.
__ lw(scratch, FieldMemOperand(receiver, JSArray::kPropertiesOffset));
__ lw(scratch, FieldMemOperand(scratch, FixedArray::kMapOffset));
__ LoadRoot(at, Heap::kHashTableMapRootIndex);
__ Branch(&miss, eq, scratch, Operand(at));
// Check that value is a smi.
__ JumpIfNotSmi(value, &miss);
// Prepare tail call to StoreIC_ArrayLength.
__ Push(receiver, value);
ExternalReference ref = ExternalReference(IC_Utility(kStoreIC_ArrayLength),
masm->isolate());
__ TailCallExternalReference(ref, 2, 1);
__ bind(&miss);
GenerateMiss(masm);
}
void StoreIC::GenerateNormal(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- a0 : value
......
......@@ -579,6 +579,15 @@ void StubCompiler::GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind) {
}
void StubCompiler::GenerateStoreMiss(MacroAssembler* masm, Code::Kind kind) {
ASSERT(kind == Code::STORE_IC || kind == Code::KEYED_STORE_IC);
Handle<Code> code = (kind == Code::STORE_IC)
? masm->isolate()->builtins()->StoreIC_Miss()
: masm->isolate()->builtins()->KeyedStoreIC_Miss();
__ Jump(code, RelocInfo::CODE_TARGET);
}
static void GenerateCallFunction(MacroAssembler* masm,
Handle<Object> object,
const ParameterCount& arguments,
......
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