| Index: src/arm64/code-stubs-arm64.cc
|
| diff --git a/src/arm64/code-stubs-arm64.cc b/src/arm64/code-stubs-arm64.cc
|
| index 2ec451eeaa57d3a6e99c3b64343e209f4777cbfa..33c6fbf12af52319fc58d9e9cd5b4e3926d621d5 100644
|
| --- a/src/arm64/code-stubs-arm64.cc
|
| +++ b/src/arm64/code-stubs-arm64.cc
|
| @@ -1585,24 +1585,35 @@ void InstanceOfStub::Generate(MacroAssembler* masm) {
|
|
|
| // Loop through the prototype chain looking for the {function} prototype.
|
| // Assume true, and change to false if not found.
|
| - Register const object_prototype = object_map;
|
| + Register const object_instance_type = function_map;
|
| Register const null = scratch;
|
| - Label done, loop;
|
| - __ LoadRoot(x0, Heap::kTrueValueRootIndex);
|
| + Register const result = x0;
|
| + Label done, loop, proxy_case;
|
| + __ LoadRoot(result, Heap::kTrueValueRootIndex);
|
| __ LoadRoot(null, Heap::kNullValueRootIndex);
|
| __ Bind(&loop);
|
| - __ Ldr(object_prototype, FieldMemOperand(object_map, Map::kPrototypeOffset));
|
| - __ Cmp(object_prototype, function_prototype);
|
| + __ CompareInstanceType(object_map, object_instance_type, JS_PROXY_TYPE);
|
| + __ B(eq, &proxy_case);
|
| + __ Ldr(object, FieldMemOperand(object_map, Map::kPrototypeOffset));
|
| + __ Cmp(object, function_prototype);
|
| __ B(eq, &done);
|
| - __ Cmp(object_prototype, null);
|
| - __ Ldr(object_map, FieldMemOperand(object_prototype, HeapObject::kMapOffset));
|
| + __ Cmp(object, null);
|
| + __ Ldr(object_map, FieldMemOperand(object, HeapObject::kMapOffset));
|
| __ B(ne, &loop);
|
| - __ LoadRoot(x0, Heap::kFalseValueRootIndex);
|
| + __ LoadRoot(result, Heap::kFalseValueRootIndex);
|
| __ Bind(&done);
|
| - __ StoreRoot(x0, Heap::kInstanceofCacheAnswerRootIndex);
|
| + __ StoreRoot(result, Heap::kInstanceofCacheAnswerRootIndex);
|
| __ Ret();
|
|
|
| - // Slow-case: Call the runtime function.
|
| + // Proxy-case: Call the %HasInPrototypeChain runtime function.
|
| + __ Bind(&proxy_case);
|
| + __ Push(object, function_prototype);
|
| + // Invalidate the instanceof cache.
|
| + __ Move(scratch, Smi::FromInt(0));
|
| + __ StoreRoot(scratch, Heap::kInstanceofCacheFunctionRootIndex);
|
| + __ TailCallRuntime(Runtime::kHasInPrototypeChain, 2, 1);
|
| +
|
| + // Slow-case: Call the %InstanceOf runtime function.
|
| __ bind(&slow_case);
|
| __ Push(object, function);
|
| __ TailCallRuntime(Runtime::kInstanceOf, 2, 1);
|
|
|