Index: src/mips/code-stubs-mips.cc |
diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc |
index 8c2f747a5c232b6b6a0734ddf6689994512eb3a9..40849646623a90b452a6d69164f6c6572f16aeeb 100644 |
--- a/src/mips/code-stubs-mips.cc |
+++ b/src/mips/code-stubs-mips.cc |
@@ -1454,128 +1454,6 @@ void LoadIndexedStringStub::Generate(MacroAssembler* masm) { |
} |
-void InstanceOfStub::Generate(MacroAssembler* masm) { |
- Register const object = a1; // Object (lhs). |
- Register const function = a0; // Function (rhs). |
- Register const object_map = a2; // Map of {object}. |
- Register const function_map = a3; // Map of {function}. |
- Register const function_prototype = t0; // Prototype of {function}. |
- Register const scratch = t1; |
- |
- DCHECK(object.is(InstanceOfDescriptor::LeftRegister())); |
- DCHECK(function.is(InstanceOfDescriptor::RightRegister())); |
- |
- // Check if {object} is a smi. |
- Label object_is_smi; |
- __ JumpIfSmi(object, &object_is_smi); |
- |
- // Lookup the {function} and the {object} map in the global instanceof cache. |
- // Note: This is safe because we clear the global instanceof cache whenever |
- // we change the prototype of any object. |
- Label fast_case, slow_case; |
- __ lw(object_map, FieldMemOperand(object, HeapObject::kMapOffset)); |
- __ LoadRoot(at, Heap::kInstanceofCacheFunctionRootIndex); |
- __ Branch(&fast_case, ne, function, Operand(at)); |
- __ LoadRoot(at, Heap::kInstanceofCacheMapRootIndex); |
- __ Branch(&fast_case, ne, object_map, Operand(at)); |
- __ Ret(USE_DELAY_SLOT); |
- __ LoadRoot(v0, Heap::kInstanceofCacheAnswerRootIndex); // In delay slot. |
- |
- // If {object} is a smi we can safely return false if {function} is a JS |
- // function, otherwise we have to miss to the runtime and throw an exception. |
- __ bind(&object_is_smi); |
- __ JumpIfSmi(function, &slow_case); |
- __ GetObjectType(function, function_map, scratch); |
- __ Branch(&slow_case, ne, scratch, Operand(JS_FUNCTION_TYPE)); |
- __ Ret(USE_DELAY_SLOT); |
- __ LoadRoot(v0, Heap::kFalseValueRootIndex); // In delay slot. |
- |
- // Fast-case: The {function} must be a valid JSFunction. |
- __ bind(&fast_case); |
- __ JumpIfSmi(function, &slow_case); |
- __ GetObjectType(function, function_map, scratch); |
- __ Branch(&slow_case, ne, scratch, Operand(JS_FUNCTION_TYPE)); |
- |
- // Go to the runtime if the function is not a constructor. |
- __ lbu(scratch, FieldMemOperand(function_map, Map::kBitFieldOffset)); |
- __ And(at, scratch, Operand(1 << Map::kIsConstructor)); |
- __ Branch(&slow_case, eq, at, Operand(zero_reg)); |
- |
- // Ensure that {function} has an instance prototype. |
- __ And(at, scratch, Operand(1 << Map::kHasNonInstancePrototype)); |
- __ Branch(&slow_case, ne, at, Operand(zero_reg)); |
- |
- // Get the "prototype" (or initial map) of the {function}. |
- __ lw(function_prototype, |
- FieldMemOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); |
- __ AssertNotSmi(function_prototype); |
- |
- // Resolve the prototype if the {function} has an initial map. Afterwards the |
- // {function_prototype} will be either the JSReceiver prototype object or the |
- // hole value, which means that no instances of the {function} were created so |
- // far and hence we should return false. |
- Label function_prototype_valid; |
- __ GetObjectType(function_prototype, scratch, scratch); |
- __ Branch(&function_prototype_valid, ne, scratch, Operand(MAP_TYPE)); |
- __ lw(function_prototype, |
- FieldMemOperand(function_prototype, Map::kPrototypeOffset)); |
- __ bind(&function_prototype_valid); |
- __ AssertNotSmi(function_prototype); |
- |
- // Update the global instanceof cache with the current {object} map and |
- // {function}. The cached answer will be set when it is known below. |
- __ StoreRoot(function, Heap::kInstanceofCacheFunctionRootIndex); |
- __ StoreRoot(object_map, Heap::kInstanceofCacheMapRootIndex); |
- |
- // Loop through the prototype chain looking for the {function} prototype. |
- // Assume true, and change to false if not found. |
- Register const object_instance_type = function_map; |
- Register const map_bit_field = function_map; |
- Register const null = scratch; |
- Register const result = v0; |
- |
- Label done, loop, fast_runtime_fallback; |
- __ LoadRoot(result, Heap::kTrueValueRootIndex); |
- __ LoadRoot(null, Heap::kNullValueRootIndex); |
- __ bind(&loop); |
- |
- // Check if the object needs to be access checked. |
- __ lbu(map_bit_field, FieldMemOperand(object_map, Map::kBitFieldOffset)); |
- __ And(map_bit_field, map_bit_field, Operand(1 << Map::kIsAccessCheckNeeded)); |
- __ Branch(&fast_runtime_fallback, ne, map_bit_field, Operand(zero_reg)); |
- // Check if the current object is a Proxy. |
- __ lbu(object_instance_type, |
- FieldMemOperand(object_map, Map::kInstanceTypeOffset)); |
- __ Branch(&fast_runtime_fallback, eq, object_instance_type, |
- Operand(JS_PROXY_TYPE)); |
- |
- __ lw(object, FieldMemOperand(object_map, Map::kPrototypeOffset)); |
- __ Branch(&done, eq, object, Operand(function_prototype)); |
- __ Branch(USE_DELAY_SLOT, &loop, ne, object, Operand(null)); |
- __ lw(object_map, |
- FieldMemOperand(object, HeapObject::kMapOffset)); // In delay slot. |
- __ LoadRoot(result, Heap::kFalseValueRootIndex); |
- __ bind(&done); |
- __ Ret(USE_DELAY_SLOT); |
- __ StoreRoot(result, |
- Heap::kInstanceofCacheAnswerRootIndex); // In delay slot. |
- |
- // Found Proxy or access check needed: Call the runtime |
- __ bind(&fast_runtime_fallback); |
- __ Push(object, function_prototype); |
- // Invalidate the instanceof cache. |
- DCHECK(Smi::FromInt(0) == 0); |
- __ StoreRoot(zero_reg, Heap::kInstanceofCacheFunctionRootIndex); |
- __ TailCallRuntime(Runtime::kHasInPrototypeChain); |
- |
- // Slow-case: Call the %InstanceOf runtime function. |
- __ bind(&slow_case); |
- __ Push(object, function); |
- __ TailCallRuntime(is_es6_instanceof() ? Runtime::kOrdinaryHasInstance |
- : Runtime::kInstanceOf); |
-} |
- |
- |
void FunctionPrototypeStub::Generate(MacroAssembler* masm) { |
Label miss; |
Register receiver = LoadDescriptor::ReceiverRegister(); |