Commit c902d4ff authored by mbrandy's avatar mbrandy Committed by Commit bot

PPC: [proxies] InstanceOfStub should bailout to %HasInPrototypeChain for proxies.

Port 0e956833

Original commit message:
    Whenever the InstanceOfStub finds a proxy (either passed as object or
    somewhere on the prototype chain), it should bailout to the
    %HasInPrototypeChain runtime function, which will do the right thing
    (soonish).

R=bmeurer@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=v8:1543
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#32586}
parent 3950206f
...@@ -1457,26 +1457,35 @@ void InstanceOfStub::Generate(MacroAssembler* masm) { ...@@ -1457,26 +1457,35 @@ void InstanceOfStub::Generate(MacroAssembler* masm) {
// Loop through the prototype chain looking for the {function} prototype. // Loop through the prototype chain looking for the {function} prototype.
// Assume true, and change to false if not found. // 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; Register const null = scratch;
Label done, loop; Register const result = r3;
__ LoadRoot(r3, Heap::kTrueValueRootIndex); Label done, loop, proxy_case;
__ LoadRoot(result, Heap::kTrueValueRootIndex);
__ LoadRoot(null, Heap::kNullValueRootIndex); __ LoadRoot(null, Heap::kNullValueRootIndex);
__ bind(&loop); __ bind(&loop);
__ LoadP(object_prototype, __ CompareInstanceType(object_map, object_instance_type, JS_PROXY_TYPE);
FieldMemOperand(object_map, Map::kPrototypeOffset)); __ beq(&proxy_case);
__ cmp(object_prototype, function_prototype); __ LoadP(object, FieldMemOperand(object_map, Map::kPrototypeOffset));
__ cmp(object, function_prototype);
__ beq(&done); __ beq(&done);
__ cmp(object_prototype, null); __ cmp(object, null);
__ LoadP(object_map, __ LoadP(object_map, FieldMemOperand(object, HeapObject::kMapOffset));
FieldMemOperand(object_prototype, HeapObject::kMapOffset));
__ bne(&loop); __ bne(&loop);
__ LoadRoot(r3, Heap::kFalseValueRootIndex); __ LoadRoot(result, Heap::kFalseValueRootIndex);
__ bind(&done); __ bind(&done);
__ StoreRoot(r3, Heap::kInstanceofCacheAnswerRootIndex); __ StoreRoot(result, Heap::kInstanceofCacheAnswerRootIndex);
__ Ret(); __ 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.
__ LoadSmiLiteral(scratch, Smi::FromInt(0));
__ StoreRoot(scratch, Heap::kInstanceofCacheFunctionRootIndex);
__ TailCallRuntime(Runtime::kHasInPrototypeChain, 2, 1);
// Slow-case: Call the %InstanceOf runtime function.
__ bind(&slow_case); __ bind(&slow_case);
__ Push(object, function); __ Push(object, function);
__ TailCallRuntime(Runtime::kInstanceOf, 2, 1); __ TailCallRuntime(Runtime::kInstanceOf, 2, 1);
......
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