Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Unified Diff: src/x64/code-stubs-x64.cc

Issue 1492243003: [proxies] InstanceOfStub should bailout to %HasInPrototypeChain for proxies. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix mips/mips64. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/mips64/code-stubs-mips64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/code-stubs-x64.cc
diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc
index bb5485303bc2b70c0ceec5563161ea716e3b8aef..037503edb990c1ff0c990572a91634bcbe7a2045 100644
--- a/src/x64/code-stubs-x64.cc
+++ b/src/x64/code-stubs-x64.cc
@@ -2538,22 +2538,34 @@ 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;
- Label done, loop;
+ Label done, loop, proxy_case;
__ LoadRoot(rax, Heap::kTrueValueRootIndex);
__ bind(&loop);
- __ movp(object_prototype, FieldOperand(object_map, Map::kPrototypeOffset));
- __ cmpp(object_prototype, function_prototype);
+ __ CmpInstanceType(object_map, JS_PROXY_TYPE);
+ __ j(equal, &proxy_case, Label::kNear);
+ __ movp(object, FieldOperand(object_map, Map::kPrototypeOffset));
+ __ cmpp(object, function_prototype);
__ j(equal, &done, Label::kNear);
- __ CompareRoot(object_prototype, Heap::kNullValueRootIndex);
- __ movp(object_map, FieldOperand(object_prototype, HeapObject::kMapOffset));
+ __ CompareRoot(object, Heap::kNullValueRootIndex);
+ __ movp(object_map, FieldOperand(object, HeapObject::kMapOffset));
__ j(not_equal, &loop);
__ LoadRoot(rax, Heap::kFalseValueRootIndex);
__ bind(&done);
__ StoreRoot(rax, Heap::kInstanceofCacheAnswerRootIndex);
__ ret(0);
- // Slow-case: Call the runtime function.
+ // Proxy-case: Call the %HasInPrototypeChain runtime function.
+ __ bind(&proxy_case);
+ __ PopReturnAddressTo(kScratchRegister);
+ __ Push(object);
+ __ Push(function_prototype);
+ __ PushReturnAddressFrom(kScratchRegister);
+ // Invalidate the instanceof cache.
+ __ Move(rax, Smi::FromInt(0));
+ __ StoreRoot(rax, Heap::kInstanceofCacheFunctionRootIndex);
+ __ TailCallRuntime(Runtime::kHasInPrototypeChain, 2, 1);
+
+ // Slow-case: Call the %InstanceOf runtime function.
__ bind(&slow_case);
__ PopReturnAddressTo(kScratchRegister);
__ Push(object);
« no previous file with comments | « src/mips64/code-stubs-mips64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698