| Index: src/mips/stub-cache-mips.cc
|
| ===================================================================
|
| --- src/mips/stub-cache-mips.cc (revision 9808)
|
| +++ src/mips/stub-cache-mips.cc (working copy)
|
| @@ -99,7 +99,61 @@
|
| // must always call a backup property check that is complete.
|
| // This function is safe to call if the receiver has fast properties.
|
| // Name must be a symbol and receiver must be a heap object.
|
| -MUST_USE_RESULT static MaybeObject* GenerateDictionaryNegativeLookup(
|
| +static void GenerateDictionaryNegativeLookup(MacroAssembler* masm,
|
| + Label* miss_label,
|
| + Register receiver,
|
| + Handle<String> name,
|
| + Register scratch0,
|
| + Register scratch1) {
|
| + ASSERT(name->IsSymbol());
|
| + Counters* counters = masm->isolate()->counters();
|
| + __ IncrementCounter(counters->negative_lookups(), 1, scratch0, scratch1);
|
| + __ IncrementCounter(counters->negative_lookups_miss(), 1, scratch0, scratch1);
|
| +
|
| + Label done;
|
| +
|
| + const int kInterceptorOrAccessCheckNeededMask =
|
| + (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded);
|
| +
|
| + // Bail out if the receiver has a named interceptor or requires access checks.
|
| + Register map = scratch1;
|
| + __ lw(map, FieldMemOperand(receiver, HeapObject::kMapOffset));
|
| + __ lbu(scratch0, FieldMemOperand(map, Map::kBitFieldOffset));
|
| + __ And(scratch0, scratch0, Operand(kInterceptorOrAccessCheckNeededMask));
|
| + __ Branch(miss_label, ne, scratch0, Operand(zero_reg));
|
| +
|
| + // Check that receiver is a JSObject.
|
| + __ lbu(scratch0, FieldMemOperand(map, Map::kInstanceTypeOffset));
|
| + __ Branch(miss_label, lt, scratch0, Operand(FIRST_SPEC_OBJECT_TYPE));
|
| +
|
| + // Load properties array.
|
| + Register properties = scratch0;
|
| + __ lw(properties, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
|
| + // Check that the properties array is a dictionary.
|
| + __ lw(map, FieldMemOperand(properties, HeapObject::kMapOffset));
|
| + Register tmp = properties;
|
| + __ LoadRoot(tmp, Heap::kHashTableMapRootIndex);
|
| + __ Branch(miss_label, ne, map, Operand(tmp));
|
| +
|
| + // Restore the temporarily used register.
|
| + __ lw(properties, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
|
| +
|
| +
|
| + StringDictionaryLookupStub::GenerateNegativeLookup(masm,
|
| + miss_label,
|
| + &done,
|
| + receiver,
|
| + properties,
|
| + name,
|
| + scratch1);
|
| + __ bind(&done);
|
| + __ DecrementCounter(counters->negative_lookups_miss(), 1, scratch0, scratch1);
|
| +}
|
| +
|
| +
|
| +// TODO(kmillikin): Eliminate this function when the stub cache is fully
|
| +// handlified.
|
| +MUST_USE_RESULT static MaybeObject* TryGenerateDictionaryNegativeLookup(
|
| MacroAssembler* masm,
|
| Label* miss_label,
|
| Register receiver,
|
| @@ -140,7 +194,7 @@
|
| // Restore the temporarily used register.
|
| __ lw(properties, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
|
|
|
| - MaybeObject* result = StringDictionaryLookupStub::GenerateNegativeLookup(
|
| + MaybeObject* result = StringDictionaryLookupStub::TryGenerateNegativeLookup(
|
| masm,
|
| miss_label,
|
| &done,
|
| @@ -261,8 +315,10 @@
|
| // are loaded directly otherwise the property is loaded from the properties
|
| // fixed array.
|
| void StubCompiler::GenerateFastPropertyLoad(MacroAssembler* masm,
|
| - Register dst, Register src,
|
| - JSObject* holder, int index) {
|
| + Register dst,
|
| + Register src,
|
| + Handle<JSObject> holder,
|
| + int index) {
|
| // Adjust for the number of properties stored in the holder.
|
| index -= holder->map()->inobject_properties();
|
| if (index < 0) {
|
| @@ -469,20 +525,15 @@
|
|
|
| void StubCompiler::GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind) {
|
| ASSERT(kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC);
|
| - Code* code = NULL;
|
| - if (kind == Code::LOAD_IC) {
|
| - code = masm->isolate()->builtins()->builtin(Builtins::kLoadIC_Miss);
|
| - } else {
|
| - code = masm->isolate()->builtins()->builtin(Builtins::kKeyedLoadIC_Miss);
|
| - }
|
| -
|
| - Handle<Code> ic(code);
|
| - __ Jump(ic, RelocInfo::CODE_TARGET);
|
| + Handle<Code> code = (kind == Code::LOAD_IC)
|
| + ? masm->isolate()->builtins()->LoadIC_Miss()
|
| + : masm->isolate()->builtins()->KeyedLoadIC_Miss();
|
| + __ Jump(code, RelocInfo::CODE_TARGET);
|
| }
|
|
|
|
|
| static void GenerateCallFunction(MacroAssembler* masm,
|
| - Object* object,
|
| + Handle<Object> object,
|
| const ParameterCount& arguments,
|
| Label* miss,
|
| Code::ExtraICState extra_ic_state) {
|
| @@ -878,7 +929,25 @@
|
| // 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.
|
| -MUST_USE_RESULT static MaybeObject* GenerateCheckPropertyCell(
|
| +static void GenerateCheckPropertyCell(MacroAssembler* masm,
|
| + Handle<GlobalObject> global,
|
| + Handle<String> name,
|
| + Register scratch,
|
| + Label* miss) {
|
| + Handle<JSGlobalPropertyCell> cell =
|
| + GlobalObject::EnsurePropertyCell(global, name);
|
| + ASSERT(cell->value()->IsTheHole());
|
| + __ li(scratch, Operand(cell));
|
| + __ lw(scratch,
|
| + FieldMemOperand(scratch, JSGlobalPropertyCell::kValueOffset));
|
| + __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
|
| + __ Branch(miss, ne, scratch, Operand(at));
|
| +}
|
| +
|
| +
|
| +// TODO(kmillikin): Eliminate this function when the stub cache is fully
|
| +// handlified.
|
| +MUST_USE_RESULT static MaybeObject* TryGenerateCheckPropertyCell(
|
| MacroAssembler* masm,
|
| GlobalObject* global,
|
| String* name,
|
| @@ -901,7 +970,29 @@
|
|
|
| // Calls GenerateCheckPropertyCell for each global object in the prototype chain
|
| // from object to (but not including) holder.
|
| -MUST_USE_RESULT static MaybeObject* GenerateCheckPropertyCells(
|
| +static void GenerateCheckPropertyCells(MacroAssembler* masm,
|
| + Handle<JSObject> object,
|
| + Handle<JSObject> holder,
|
| + Handle<String> name,
|
| + Register scratch,
|
| + Label* miss) {
|
| + Handle<JSObject> current = object;
|
| + while (!current.is_identical_to(holder)) {
|
| + if (current->IsGlobalObject()) {
|
| + GenerateCheckPropertyCell(masm,
|
| + Handle<GlobalObject>::cast(current),
|
| + name,
|
| + scratch,
|
| + miss);
|
| + }
|
| + current = Handle<JSObject>(JSObject::cast(current->GetPrototype()));
|
| + }
|
| +}
|
| +
|
| +
|
| +// TODO(kmillikin): Eliminate this function when the stub cache is fully
|
| +// handlified.
|
| +MUST_USE_RESULT static MaybeObject* TryGenerateCheckPropertyCells(
|
| MacroAssembler* masm,
|
| JSObject* object,
|
| JSObject* holder,
|
| @@ -912,7 +1003,7 @@
|
| while (current != holder) {
|
| if (current->IsGlobalObject()) {
|
| // Returns a cell or a failure.
|
| - MaybeObject* result = GenerateCheckPropertyCell(
|
| + MaybeObject* result = TryGenerateCheckPropertyCell(
|
| masm,
|
| GlobalObject::cast(current),
|
| name,
|
| @@ -1047,6 +1138,108 @@
|
| #define __ ACCESS_MASM(masm())
|
|
|
|
|
| +Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
|
| + Register object_reg,
|
| + Handle<JSObject> holder,
|
| + Register holder_reg,
|
| + Register scratch1,
|
| + Register scratch2,
|
| + Handle<String> name,
|
| + int save_at_depth,
|
| + Label* miss) {
|
| + // Make sure there's no overlap between holder and object registers.
|
| + ASSERT(!scratch1.is(object_reg) && !scratch1.is(holder_reg));
|
| + ASSERT(!scratch2.is(object_reg) && !scratch2.is(holder_reg)
|
| + && !scratch2.is(scratch1));
|
| +
|
| + // Keep track of the current object in register reg.
|
| + Register reg = object_reg;
|
| + int depth = 0;
|
| +
|
| + if (save_at_depth == depth) {
|
| + __ sw(reg, MemOperand(sp));
|
| + }
|
| +
|
| + // Check the maps in the prototype chain.
|
| + // Traverse the prototype chain from the object and do map checks.
|
| + Handle<JSObject> current = object;
|
| + while (!current.is_identical_to(holder)) {
|
| + ++depth;
|
| +
|
| + // Only global objects and objects that do not require access
|
| + // checks are allowed in stubs.
|
| + ASSERT(current->IsJSGlobalProxy() || !current->IsAccessCheckNeeded());
|
| +
|
| + Handle<JSObject> prototype(JSObject::cast(current->GetPrototype()));
|
| + if (!current->HasFastProperties() &&
|
| + !current->IsJSGlobalObject() &&
|
| + !current->IsJSGlobalProxy()) {
|
| + if (!name->IsSymbol()) {
|
| + name = factory()->LookupSymbol(name);
|
| + }
|
| + ASSERT(current->property_dictionary()->FindEntry(*name) ==
|
| + StringDictionary::kNotFound);
|
| +
|
| + GenerateDictionaryNegativeLookup(masm(), miss, reg, name,
|
| + scratch1, scratch2);
|
| +
|
| + __ lw(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset));
|
| + reg = holder_reg; // From now on the object will be in holder_reg.
|
| + __ lw(reg, FieldMemOperand(scratch1, Map::kPrototypeOffset));
|
| + } else {
|
| + Handle<Map> current_map(current->map());
|
| + __ lw(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset));
|
| + // Branch on the result of the map check.
|
| + __ Branch(miss, ne, scratch1, Operand(current_map));
|
| + // Check access rights to the global object. This has to happen after
|
| + // the map check so that we know that the object is actually a global
|
| + // object.
|
| + if (current->IsJSGlobalProxy()) {
|
| + __ CheckAccessGlobalProxy(reg, scratch2, miss);
|
| + }
|
| + reg = holder_reg; // From now on the object will be in holder_reg.
|
| +
|
| + if (heap()->InNewSpace(*prototype)) {
|
| + // The prototype is in new space; we cannot store a reference to it
|
| + // in the code. Load it from the map.
|
| + __ lw(reg, FieldMemOperand(scratch1, Map::kPrototypeOffset));
|
| + } else {
|
| + // The prototype is in old space; load it directly.
|
| + __ li(reg, Operand(prototype));
|
| + }
|
| + }
|
| +
|
| + if (save_at_depth == depth) {
|
| + __ sw(reg, MemOperand(sp));
|
| + }
|
| +
|
| + // Go to the next object in the prototype chain.
|
| + current = prototype;
|
| + }
|
| +
|
| + // Log the check depth.
|
| + LOG(masm()->isolate(), IntEvent("check-maps-depth", depth + 1));
|
| +
|
| + // Check the holder map.
|
| + __ lw(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset));
|
| + __ Branch(miss, ne, scratch1, Operand(Handle<Map>(current->map())));
|
| +
|
| + // Perform security check for access to the global object.
|
| + ASSERT(holder->IsJSGlobalProxy() || !holder->IsAccessCheckNeeded());
|
| + if (holder->IsJSGlobalProxy()) {
|
| + __ CheckAccessGlobalProxy(reg, scratch1, miss);
|
| + }
|
| +
|
| + // If we've skipped any global objects, it's not enough to verify that
|
| + // their maps haven't changed. We also need to check that the property
|
| + // cell for the property is still empty.
|
| + GenerateCheckPropertyCells(masm(), object, holder, name, scratch1, miss);
|
| +
|
| + // Return the register containing the holder.
|
| + return reg;
|
| +}
|
| +
|
| +
|
| Register StubCompiler::CheckPrototypes(JSObject* object,
|
| Register object_reg,
|
| JSObject* holder,
|
| @@ -1096,12 +1289,14 @@
|
| ASSERT(current->property_dictionary()->FindEntry(name) ==
|
| StringDictionary::kNotFound);
|
|
|
| - MaybeObject* negative_lookup = GenerateDictionaryNegativeLookup(masm(),
|
| - miss,
|
| - reg,
|
| - name,
|
| - scratch1,
|
| - scratch2);
|
| + MaybeObject* negative_lookup =
|
| + TryGenerateDictionaryNegativeLookup(masm(),
|
| + miss,
|
| + reg,
|
| + name,
|
| + scratch1,
|
| + scratch2);
|
| +
|
| if (negative_lookup->IsFailure()) {
|
| set_failure(Failure::cast(negative_lookup));
|
| return reg;
|
| @@ -1166,18 +1361,18 @@
|
| ASSERT(holder->IsJSGlobalProxy() || !holder->IsAccessCheckNeeded());
|
| if (holder->IsJSGlobalProxy()) {
|
| __ CheckAccessGlobalProxy(reg, scratch1, miss);
|
| - };
|
| + }
|
|
|
| // If we've skipped any global objects, it's not enough to verify
|
| // that their maps haven't changed. We also need to check that the
|
| // property cell for the property is still empty.
|
|
|
| - MaybeObject* result = GenerateCheckPropertyCells(masm(),
|
| - object,
|
| - holder,
|
| - name,
|
| - scratch1,
|
| - miss);
|
| + MaybeObject* result = TryGenerateCheckPropertyCells(masm(),
|
| + object,
|
| + holder,
|
| + name,
|
| + scratch1,
|
| + miss);
|
| if (result->IsFailure()) set_failure(Failure::cast(result));
|
|
|
| // Return the register containing the holder.
|
| @@ -1185,36 +1380,35 @@
|
| }
|
|
|
|
|
| -void StubCompiler::GenerateLoadField(JSObject* object,
|
| - JSObject* holder,
|
| +void StubCompiler::GenerateLoadField(Handle<JSObject> object,
|
| + Handle<JSObject> holder,
|
| Register receiver,
|
| Register scratch1,
|
| Register scratch2,
|
| Register scratch3,
|
| int index,
|
| - String* name,
|
| + Handle<String> name,
|
| Label* miss) {
|
| // Check that the receiver isn't a smi.
|
| __ And(scratch1, receiver, Operand(kSmiTagMask));
|
| __ Branch(miss, eq, scratch1, Operand(zero_reg));
|
|
|
| // Check that the maps haven't changed.
|
| - Register reg =
|
| - CheckPrototypes(object, receiver, holder, scratch1, scratch2, scratch3,
|
| - name, miss);
|
| + Register reg = CheckPrototypes(
|
| + object, receiver, holder, scratch1, scratch2, scratch3, name, miss);
|
| GenerateFastPropertyLoad(masm(), v0, reg, holder, index);
|
| __ Ret();
|
| }
|
|
|
|
|
| -void StubCompiler::GenerateLoadConstant(JSObject* object,
|
| - JSObject* holder,
|
| +void StubCompiler::GenerateLoadConstant(Handle<JSObject> object,
|
| + Handle<JSObject> holder,
|
| Register receiver,
|
| Register scratch1,
|
| Register scratch2,
|
| Register scratch3,
|
| - Object* value,
|
| - String* name,
|
| + Handle<Object> value,
|
| + Handle<String> name,
|
| Label* miss) {
|
| // Check that the receiver isn't a smi.
|
| __ JumpIfSmi(receiver, miss, scratch1);
|
| @@ -1225,7 +1419,7 @@
|
| scratch1, scratch2, scratch3, name, miss);
|
|
|
| // Return the constant value.
|
| - __ li(v0, Operand(Handle<Object>(value)));
|
| + __ li(v0, Operand(value));
|
| __ Ret();
|
| }
|
|
|
| @@ -1390,7 +1584,8 @@
|
| // We found FIELD property in prototype chain of interceptor's holder.
|
| // Retrieve a field from field's holder.
|
| GenerateFastPropertyLoad(masm(), v0, holder_reg,
|
| - lookup->holder(), lookup->GetFieldIndex());
|
| + Handle<JSObject>(lookup->holder()),
|
| + lookup->GetFieldIndex());
|
| __ Ret();
|
| } else {
|
| // We found CALLBACKS property in prototype chain of interceptor's
|
| @@ -1440,9 +1635,9 @@
|
| }
|
|
|
|
|
| -void CallStubCompiler::GenerateNameCheck(String* name, Label* miss) {
|
| +void CallStubCompiler::GenerateNameCheck(Handle<String> name, Label* miss) {
|
| if (kind_ == Code::KEYED_CALL_IC) {
|
| - __ Branch(miss, ne, a2, Operand(Handle<String>(name)));
|
| + __ Branch(miss, ne, a2, Operand(name));
|
| }
|
| }
|
|
|
| @@ -1499,11 +1694,22 @@
|
| }
|
|
|
|
|
| -MaybeObject* CallStubCompiler::GenerateMissBranch() {
|
| - MaybeObject* maybe_obj =
|
| +void CallStubCompiler::GenerateMissBranch() {
|
| + Handle<Code> code =
|
| isolate()->stub_cache()->ComputeCallMiss(arguments().immediate(),
|
| kind_,
|
| - extra_ic_state_);
|
| + extra_state_);
|
| + __ Jump(code, RelocInfo::CODE_TARGET);
|
| +}
|
| +
|
| +
|
| +// TODO(kmillikin): Eliminate this function when the stub cache is fully
|
| +// handlified.
|
| +MaybeObject* CallStubCompiler::TryGenerateMissBranch() {
|
| + MaybeObject* maybe_obj =
|
| + isolate()->stub_cache()->TryComputeCallMiss(arguments().immediate(),
|
| + kind_,
|
| + extra_state_);
|
| Object* obj;
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| __ Jump(Handle<Code>(Code::cast(obj)), RelocInfo::CODE_TARGET);
|
| @@ -1511,10 +1717,10 @@
|
| }
|
|
|
|
|
| -MaybeObject* CallStubCompiler::CompileCallField(JSObject* object,
|
| - JSObject* holder,
|
| +Handle<Code> CallStubCompiler::CompileCallField(Handle<JSObject> object,
|
| + Handle<JSObject> holder,
|
| int index,
|
| - String* name) {
|
| + Handle<String> name) {
|
| // ----------- S t a t e -------------
|
| // -- a2 : name
|
| // -- ra : return address
|
| @@ -1534,12 +1740,11 @@
|
| Register reg = CheckPrototypes(object, a0, holder, a1, a3, t0, name, &miss);
|
| GenerateFastPropertyLoad(masm(), a1, reg, holder, index);
|
|
|
| - GenerateCallFunction(masm(), object, arguments(), &miss, extra_ic_state_);
|
| + GenerateCallFunction(masm(), object, arguments(), &miss, extra_state_);
|
|
|
| // Handle call cache miss.
|
| __ bind(&miss);
|
| - MaybeObject* maybe_result = GenerateMissBranch();
|
| - if (maybe_result->IsFailure()) return maybe_result;
|
| + GenerateMissBranch();
|
|
|
| // Return the generated code.
|
| return GetCode(FIELD, name);
|
| @@ -1564,7 +1769,7 @@
|
|
|
| Label miss;
|
|
|
| - GenerateNameCheck(name, &miss);
|
| + GenerateNameCheck(Handle<String>(name), &miss);
|
|
|
| Register receiver = a1;
|
|
|
| @@ -1640,7 +1845,7 @@
|
| __ bind(&with_write_barrier);
|
|
|
| __ lw(t2, FieldMemOperand(receiver, HeapObject::kMapOffset));
|
| - __ CheckFastSmiOnlyElements(t2, t2, &call_builtin);
|
| + __ CheckFastObjectElements(t2, t2, &call_builtin);
|
|
|
| // Save new length.
|
| __ sw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset));
|
| @@ -1730,11 +1935,11 @@
|
|
|
| // Handle call cache miss.
|
| __ bind(&miss);
|
| - MaybeObject* maybe_result = GenerateMissBranch();
|
| + MaybeObject* maybe_result = TryGenerateMissBranch();
|
| if (maybe_result->IsFailure()) return maybe_result;
|
|
|
| // Return the generated code.
|
| - return GetCode(function);
|
| + return TryGetCode(function);
|
| }
|
|
|
|
|
| @@ -1759,7 +1964,7 @@
|
| Register receiver = a1;
|
| Register elements = a3;
|
|
|
| - GenerateNameCheck(name, &miss);
|
| + GenerateNameCheck(Handle<String>(name), &miss);
|
|
|
| // Get the receiver from the stack.
|
| const int argc = arguments().immediate();
|
| @@ -1819,11 +2024,11 @@
|
|
|
| // Handle call cache miss.
|
| __ bind(&miss);
|
| - MaybeObject* maybe_result = GenerateMissBranch();
|
| + MaybeObject* maybe_result = TryGenerateMissBranch();
|
| if (maybe_result->IsFailure()) return maybe_result;
|
|
|
| // Return the generated code.
|
| - return GetCode(function);
|
| + return TryGetCode(function);
|
| }
|
|
|
|
|
| @@ -1853,12 +2058,12 @@
|
| Label* index_out_of_range_label = &index_out_of_range;
|
|
|
| if (kind_ == Code::CALL_IC &&
|
| - (CallICBase::StringStubState::decode(extra_ic_state_) ==
|
| + (CallICBase::StringStubState::decode(extra_state_) ==
|
| DEFAULT_STRING_STUB)) {
|
| index_out_of_range_label = &miss;
|
| }
|
|
|
| - GenerateNameCheck(name, &name_miss);
|
| + GenerateNameCheck(Handle<String>(name), &name_miss);
|
|
|
| // Check that the maps starting from the prototype haven't changed.
|
| GenerateDirectLoadGlobalFunctionPrototype(masm(),
|
| @@ -1906,11 +2111,11 @@
|
| // Restore function name in a2.
|
| __ li(a2, Handle<String>(name));
|
| __ bind(&name_miss);
|
| - MaybeObject* maybe_result = GenerateMissBranch();
|
| + MaybeObject* maybe_result = TryGenerateMissBranch();
|
| if (maybe_result->IsFailure()) return maybe_result;
|
|
|
| // Return the generated code.
|
| - return GetCode(function);
|
| + return TryGetCode(function);
|
| }
|
|
|
|
|
| @@ -1939,12 +2144,12 @@
|
| Label* index_out_of_range_label = &index_out_of_range;
|
|
|
| if (kind_ == Code::CALL_IC &&
|
| - (CallICBase::StringStubState::decode(extra_ic_state_) ==
|
| + (CallICBase::StringStubState::decode(extra_state_) ==
|
| DEFAULT_STRING_STUB)) {
|
| index_out_of_range_label = &miss;
|
| }
|
|
|
| - GenerateNameCheck(name, &name_miss);
|
| + GenerateNameCheck(Handle<String>(name), &name_miss);
|
|
|
| // Check that the maps starting from the prototype haven't changed.
|
| GenerateDirectLoadGlobalFunctionPrototype(masm(),
|
| @@ -1994,11 +2199,11 @@
|
| // Restore function name in a2.
|
| __ li(a2, Handle<String>(name));
|
| __ bind(&name_miss);
|
| - MaybeObject* maybe_result = GenerateMissBranch();
|
| + MaybeObject* maybe_result = TryGenerateMissBranch();
|
| if (maybe_result->IsFailure()) return maybe_result;
|
|
|
| // Return the generated code.
|
| - return GetCode(function);
|
| + return TryGetCode(function);
|
| }
|
|
|
|
|
| @@ -2023,7 +2228,7 @@
|
| if (!object->IsJSObject() || argc != 1) return heap()->undefined_value();
|
|
|
| Label miss;
|
| - GenerateNameCheck(name, &miss);
|
| + GenerateNameCheck(Handle<String>(name), &miss);
|
|
|
| if (cell == NULL) {
|
| __ lw(a1, MemOperand(sp, 1 * kPointerSize));
|
| @@ -2066,11 +2271,11 @@
|
|
|
| __ bind(&miss);
|
| // a2: function name.
|
| - MaybeObject* maybe_result = GenerateMissBranch();
|
| + MaybeObject* maybe_result = TryGenerateMissBranch();
|
| if (maybe_result->IsFailure()) return maybe_result;
|
|
|
| // Return the generated code.
|
| - return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name);
|
| + return (cell == NULL) ? TryGetCode(function) : TryGetCode(NORMAL, name);
|
| }
|
|
|
|
|
| @@ -2098,7 +2303,7 @@
|
| if (!object->IsJSObject() || argc != 1) return heap()->undefined_value();
|
|
|
| Label miss, slow;
|
| - GenerateNameCheck(name, &miss);
|
| + GenerateNameCheck(Handle<String>(name), &miss);
|
|
|
| if (cell == NULL) {
|
| __ lw(a1, MemOperand(sp, 1 * kPointerSize));
|
| @@ -2200,11 +2405,11 @@
|
|
|
| __ bind(&miss);
|
| // a2: function name.
|
| - MaybeObject* obj = GenerateMissBranch();
|
| + MaybeObject* obj = TryGenerateMissBranch();
|
| if (obj->IsFailure()) return obj;
|
|
|
| // Return the generated code.
|
| - return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name);
|
| + return (cell == NULL) ? TryGetCode(function) : TryGetCode(NORMAL, name);
|
| }
|
|
|
|
|
| @@ -2228,7 +2433,7 @@
|
| if (!object->IsJSObject() || argc != 1) return heap()->undefined_value();
|
|
|
| Label miss;
|
| - GenerateNameCheck(name, &miss);
|
| + GenerateNameCheck(Handle<String>(name), &miss);
|
|
|
| if (cell == NULL) {
|
| __ lw(a1, MemOperand(sp, 1 * kPointerSize));
|
| @@ -2302,11 +2507,11 @@
|
|
|
| __ bind(&miss);
|
| // a2: function name.
|
| - MaybeObject* maybe_result = GenerateMissBranch();
|
| + MaybeObject* maybe_result = TryGenerateMissBranch();
|
| if (maybe_result->IsFailure()) return maybe_result;
|
|
|
| // Return the generated code.
|
| - return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name);
|
| + return (cell == NULL) ? TryGetCode(function) : TryGetCode(NORMAL, name);
|
| }
|
|
|
|
|
| @@ -2332,7 +2537,7 @@
|
|
|
| Label miss, miss_before_stack_reserved;
|
|
|
| - GenerateNameCheck(name, &miss_before_stack_reserved);
|
| + GenerateNameCheck(Handle<String>(name), &miss_before_stack_reserved);
|
|
|
| // Get the receiver from the stack.
|
| const int argc = arguments().immediate();
|
| @@ -2357,11 +2562,11 @@
|
| FreeSpaceForFastApiCall(masm());
|
|
|
| __ bind(&miss_before_stack_reserved);
|
| - MaybeObject* maybe_result = GenerateMissBranch();
|
| + MaybeObject* maybe_result = TryGenerateMissBranch();
|
| if (maybe_result->IsFailure()) return maybe_result;
|
|
|
| // Return the generated code.
|
| - return GetCode(function);
|
| + return TryGetCode(function);
|
| }
|
|
|
|
|
| @@ -2385,7 +2590,7 @@
|
|
|
| Label miss;
|
|
|
| - GenerateNameCheck(name, &miss);
|
| + GenerateNameCheck(Handle<String>(name), &miss);
|
|
|
| // Get the receiver from the stack.
|
| const int argc = arguments().immediate();
|
| @@ -2484,7 +2689,7 @@
|
| UNREACHABLE();
|
| }
|
|
|
| - CallKind call_kind = CallICBase::Contextual::decode(extra_ic_state_)
|
| + CallKind call_kind = CallICBase::Contextual::decode(extra_state_)
|
| ? CALL_AS_FUNCTION
|
| : CALL_AS_METHOD;
|
| __ InvokeFunction(function, arguments(), JUMP_FUNCTION, call_kind);
|
| @@ -2492,11 +2697,11 @@
|
| // Handle call cache miss.
|
| __ bind(&miss);
|
|
|
| - MaybeObject* maybe_result = GenerateMissBranch();
|
| + MaybeObject* maybe_result = TryGenerateMissBranch();
|
| if (maybe_result->IsFailure()) return maybe_result;
|
|
|
| // Return the generated code.
|
| - return GetCode(function);
|
| + return TryGetCode(function);
|
| }
|
|
|
|
|
| @@ -2510,18 +2715,18 @@
|
|
|
| Label miss;
|
|
|
| - GenerateNameCheck(name, &miss);
|
| + GenerateNameCheck(Handle<String>(name), &miss);
|
|
|
| // Get the number of arguments.
|
| const int argc = arguments().immediate();
|
|
|
| - LookupResult lookup;
|
| + LookupResult lookup(isolate());
|
| LookupPostInterceptor(holder, name, &lookup);
|
|
|
| // Get the receiver from the stack.
|
| __ lw(a1, MemOperand(sp, argc * kPointerSize));
|
|
|
| - CallInterceptorCompiler compiler(this, arguments(), a2, extra_ic_state_);
|
| + CallInterceptorCompiler compiler(this, arguments(), a2, extra_state_);
|
| MaybeObject* result = compiler.Compile(masm(),
|
| object,
|
| holder,
|
| @@ -2541,15 +2746,16 @@
|
| // Restore receiver.
|
| __ lw(a0, MemOperand(sp, argc * kPointerSize));
|
|
|
| - GenerateCallFunction(masm(), object, arguments(), &miss, extra_ic_state_);
|
| + GenerateCallFunction(masm(), Handle<Object>(object), arguments(), &miss,
|
| + extra_state_);
|
|
|
| // Handle call cache miss.
|
| __ bind(&miss);
|
| - MaybeObject* maybe_result = GenerateMissBranch();
|
| + MaybeObject* maybe_result = TryGenerateMissBranch();
|
| if (maybe_result->IsFailure()) return maybe_result;
|
|
|
| // Return the generated code.
|
| - return GetCode(INTERCEPTOR, name);
|
| + return TryGetCode(INTERCEPTOR, name);
|
| }
|
|
|
|
|
| @@ -2574,7 +2780,7 @@
|
|
|
| Label miss;
|
|
|
| - GenerateNameCheck(name, &miss);
|
| + GenerateNameCheck(Handle<String>(name), &miss);
|
|
|
| // Get the number of arguments.
|
| const int argc = arguments().immediate();
|
| @@ -2595,32 +2801,26 @@
|
| // Jump to the cached code (tail call).
|
| Counters* counters = masm()->isolate()->counters();
|
| __ IncrementCounter(counters->call_global_inline(), 1, a3, t0);
|
| - ASSERT(function->is_compiled());
|
| Handle<Code> code(function->code());
|
| ParameterCount expected(function->shared()->formal_parameter_count());
|
| - CallKind call_kind = CallICBase::Contextual::decode(extra_ic_state_)
|
| + CallKind call_kind = CallICBase::Contextual::decode(extra_state_)
|
| ? CALL_AS_FUNCTION
|
| : CALL_AS_METHOD;
|
| - if (V8::UseCrankshaft()) {
|
| - // TODO(kasperl): For now, we always call indirectly through the
|
| - // code field in the function to allow recompilation to take effect
|
| - // without changing any of the call sites.
|
| - __ lw(a3, FieldMemOperand(a1, JSFunction::kCodeEntryOffset));
|
| - __ InvokeCode(a3, expected, arguments(), JUMP_FUNCTION,
|
| - NullCallWrapper(), call_kind);
|
| - } else {
|
| - __ InvokeCode(code, expected, arguments(), RelocInfo::CODE_TARGET,
|
| - JUMP_FUNCTION, call_kind);
|
| - }
|
| + // We call indirectly through the code field in the function to
|
| + // allow recompilation to take effect without changing any of the
|
| + // call sites.
|
| + __ lw(a3, FieldMemOperand(a1, JSFunction::kCodeEntryOffset));
|
| + __ InvokeCode(a3, expected, arguments(), JUMP_FUNCTION,
|
| + NullCallWrapper(), call_kind);
|
|
|
| // Handle call cache miss.
|
| __ bind(&miss);
|
| __ IncrementCounter(counters->call_global_inline_miss(), 1, a1, a3);
|
| - MaybeObject* maybe_result = GenerateMissBranch();
|
| + MaybeObject* maybe_result = TryGenerateMissBranch();
|
| if (maybe_result->IsFailure()) return maybe_result;
|
|
|
| // Return the generated code.
|
| - return GetCode(NORMAL, name);
|
| + return TryGetCode(NORMAL, name);
|
| }
|
|
|
|
|
| @@ -2799,9 +2999,9 @@
|
| }
|
|
|
|
|
| -MaybeObject* LoadStubCompiler::CompileLoadNonexistent(String* name,
|
| - JSObject* object,
|
| - JSObject* last) {
|
| +Handle<Code> LoadStubCompiler::CompileLoadNonexistent(Handle<String> name,
|
| + Handle<JSObject> object,
|
| + Handle<JSObject> last) {
|
| // ----------- S t a t e -------------
|
| // -- a0 : receiver
|
| // -- ra : return address
|
| @@ -2817,15 +3017,8 @@
|
| // If the last object in the prototype chain is a global object,
|
| // check that the global property cell is empty.
|
| if (last->IsGlobalObject()) {
|
| - MaybeObject* cell = GenerateCheckPropertyCell(masm(),
|
| - GlobalObject::cast(last),
|
| - name,
|
| - a1,
|
| - &miss);
|
| - if (cell->IsFailure()) {
|
| - miss.Unuse();
|
| - return cell;
|
| - }
|
| + GenerateCheckPropertyCell(
|
| + masm(), Handle<GlobalObject>::cast(last), name, a1, &miss);
|
| }
|
|
|
| // Return undefined if maps of the full prototype chain is still the same.
|
| @@ -2836,14 +3029,14 @@
|
| GenerateLoadMiss(masm(), Code::LOAD_IC);
|
|
|
| // Return the generated code.
|
| - return GetCode(NONEXISTENT, heap()->empty_string());
|
| + return GetCode(NONEXISTENT, factory()->empty_string());
|
| }
|
|
|
|
|
| -MaybeObject* LoadStubCompiler::CompileLoadField(JSObject* object,
|
| - JSObject* holder,
|
| +Handle<Code> LoadStubCompiler::CompileLoadField(Handle<JSObject> object,
|
| + Handle<JSObject> holder,
|
| int index,
|
| - String* name) {
|
| + Handle<String> name) {
|
| // ----------- S t a t e -------------
|
| // -- a0 : receiver
|
| // -- a2 : name
|
| @@ -2884,14 +3077,14 @@
|
| GenerateLoadMiss(masm(), Code::LOAD_IC);
|
|
|
| // Return the generated code.
|
| - return GetCode(CALLBACKS, name);
|
| + return TryGetCode(CALLBACKS, name);
|
| }
|
|
|
|
|
| -MaybeObject* LoadStubCompiler::CompileLoadConstant(JSObject* object,
|
| - JSObject* holder,
|
| - Object* value,
|
| - String* name) {
|
| +Handle<Code> LoadStubCompiler::CompileLoadConstant(Handle<JSObject> object,
|
| + Handle<JSObject> holder,
|
| + Handle<Object> value,
|
| + Handle<String> name) {
|
| // ----------- S t a t e -------------
|
| // -- a0 : receiver
|
| // -- a2 : name
|
| @@ -2919,7 +3112,7 @@
|
| // -----------------------------------
|
| Label miss;
|
|
|
| - LookupResult lookup;
|
| + LookupResult lookup(isolate());
|
| LookupPostInterceptor(holder, name, &lookup);
|
| GenerateLoadInterceptor(object,
|
| holder,
|
| @@ -2935,7 +3128,7 @@
|
| GenerateLoadMiss(masm(), Code::LOAD_IC);
|
|
|
| // Return the generated code.
|
| - return GetCode(INTERCEPTOR, name);
|
| + return TryGetCode(INTERCEPTOR, name);
|
| }
|
|
|
|
|
| @@ -2982,13 +3175,13 @@
|
| GenerateLoadMiss(masm(), Code::LOAD_IC);
|
|
|
| // Return the generated code.
|
| - return GetCode(NORMAL, name);
|
| + return TryGetCode(NORMAL, name);
|
| }
|
|
|
|
|
| -MaybeObject* KeyedLoadStubCompiler::CompileLoadField(String* name,
|
| - JSObject* receiver,
|
| - JSObject* holder,
|
| +Handle<Code> KeyedLoadStubCompiler::CompileLoadField(Handle<String> name,
|
| + Handle<JSObject> receiver,
|
| + Handle<JSObject> holder,
|
| int index) {
|
| // ----------- S t a t e -------------
|
| // -- ra : return address
|
| @@ -2998,7 +3191,7 @@
|
| Label miss;
|
|
|
| // Check the key is the cached one.
|
| - __ Branch(&miss, ne, a0, Operand(Handle<String>(name)));
|
| + __ Branch(&miss, ne, a0, Operand(name));
|
|
|
| GenerateLoadField(receiver, holder, a1, a2, a3, t0, index, name, &miss);
|
| __ bind(&miss);
|
| @@ -3033,14 +3226,15 @@
|
| __ bind(&miss);
|
| GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
|
|
|
| - return GetCode(CALLBACKS, name);
|
| + return TryGetCode(CALLBACKS, name);
|
| }
|
|
|
|
|
| -MaybeObject* KeyedLoadStubCompiler::CompileLoadConstant(String* name,
|
| - JSObject* receiver,
|
| - JSObject* holder,
|
| - Object* value) {
|
| +Handle<Code> KeyedLoadStubCompiler::CompileLoadConstant(
|
| + Handle<String> name,
|
| + Handle<JSObject> receiver,
|
| + Handle<JSObject> holder,
|
| + Handle<Object> value) {
|
| // ----------- S t a t e -------------
|
| // -- ra : return address
|
| // -- a0 : key
|
| @@ -3049,7 +3243,7 @@
|
| Label miss;
|
|
|
| // Check the key is the cached one.
|
| - __ Branch(&miss, ne, a0, Operand(Handle<String>(name)));
|
| + __ Branch(&miss, ne, a0, Operand(name));
|
|
|
| GenerateLoadConstant(receiver, holder, a1, a2, a3, t0, value, name, &miss);
|
| __ bind(&miss);
|
| @@ -3073,7 +3267,7 @@
|
| // Check the key is the cached one.
|
| __ Branch(&miss, ne, a0, Operand(Handle<String>(name)));
|
|
|
| - LookupResult lookup;
|
| + LookupResult lookup(isolate());
|
| LookupPostInterceptor(holder, name, &lookup);
|
| GenerateLoadInterceptor(receiver,
|
| holder,
|
| @@ -3088,11 +3282,12 @@
|
| __ bind(&miss);
|
| GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
|
|
|
| - return GetCode(INTERCEPTOR, name);
|
| + return TryGetCode(INTERCEPTOR, name);
|
| }
|
|
|
|
|
| -MaybeObject* KeyedLoadStubCompiler::CompileLoadArrayLength(String* name) {
|
| +Handle<Code> KeyedLoadStubCompiler::CompileLoadArrayLength(
|
| + Handle<String> name) {
|
| // ----------- S t a t e -------------
|
| // -- ra : return address
|
| // -- a0 : key
|
| @@ -3101,7 +3296,7 @@
|
| Label miss;
|
|
|
| // Check the key is the cached one.
|
| - __ Branch(&miss, ne, a0, Operand(Handle<String>(name)));
|
| + __ Branch(&miss, ne, a0, Operand(name));
|
|
|
| GenerateLoadArrayLength(masm(), a1, a2, &miss);
|
| __ bind(&miss);
|
| @@ -3111,7 +3306,8 @@
|
| }
|
|
|
|
|
| -MaybeObject* KeyedLoadStubCompiler::CompileLoadStringLength(String* name) {
|
| +Handle<Code> KeyedLoadStubCompiler::CompileLoadStringLength(
|
| + Handle<String> name) {
|
| // ----------- S t a t e -------------
|
| // -- ra : return address
|
| // -- a0 : key
|
| @@ -3123,7 +3319,7 @@
|
| __ IncrementCounter(counters->keyed_load_string_length(), 1, a2, a3);
|
|
|
| // Check the key is the cached one.
|
| - __ Branch(&miss, ne, a0, Operand(Handle<String>(name)));
|
| + __ Branch(&miss, ne, a0, Operand(name));
|
|
|
| GenerateLoadStringLength(masm(), a1, a2, a3, &miss, true);
|
| __ bind(&miss);
|
| @@ -3135,7 +3331,8 @@
|
| }
|
|
|
|
|
| -MaybeObject* KeyedLoadStubCompiler::CompileLoadFunctionPrototype(String* name) {
|
| +Handle<Code> KeyedLoadStubCompiler::CompileLoadFunctionPrototype(
|
| + Handle<String> name) {
|
| // ----------- S t a t e -------------
|
| // -- ra : return address
|
| // -- a0 : key
|
| @@ -3147,7 +3344,7 @@
|
| __ IncrementCounter(counters->keyed_load_function_prototype(), 1, a2, a3);
|
|
|
| // Check the name hasn't changed.
|
| - __ Branch(&miss, ne, a0, Operand(Handle<String>(name)));
|
| + __ Branch(&miss, ne, a0, Operand(name));
|
|
|
| GenerateLoadFunctionPrototype(masm(), a1, a2, a3, &miss);
|
| __ bind(&miss);
|
| @@ -3178,7 +3375,7 @@
|
| __ Jump(ic, RelocInfo::CODE_TARGET);
|
|
|
| // Return the generated code.
|
| - return GetCode(NORMAL, NULL);
|
| + return TryGetCode(NORMAL, NULL);
|
| }
|
|
|
|
|
| @@ -3206,7 +3403,7 @@
|
| __ Jump(miss_ic, RelocInfo::CODE_TARGET);
|
|
|
| // Return the generated code.
|
| - return GetCode(NORMAL, NULL, MEGAMORPHIC);
|
| + return TryGetCode(NORMAL, NULL, MEGAMORPHIC);
|
| }
|
|
|
|
|
| @@ -3299,8 +3496,8 @@
|
| __ Jump(code, RelocInfo::CODE_TARGET, eq, a3, Operand(map));
|
| } else {
|
| Label next_map;
|
| - __ Branch(&next_map, eq, a3, Operand(map));
|
| - __ li(t0, Operand(Handle<Map>(transitioned_maps->at(i))));
|
| + __ Branch(&next_map, ne, a3, Operand(map));
|
| + __ li(a3, Operand(Handle<Map>(transitioned_maps->at(i))));
|
| __ Jump(code, RelocInfo::CODE_TARGET);
|
| __ bind(&next_map);
|
| }
|
|
|