Commit e0a3ff0f authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: [proxies] fix access issue when having proxies on the prototype-chain of global objects.

  port 2c75e3d2 (r32903)

  original commit message:
  We can no longer just walk the prototype chain without doing proper access-checks. When installing a proxy as the __proto__ of the global object we might accidentally end up invoking cross-realm code
  without access-checks (see proxies-cross-realm-ecxeption.js).

BUG=

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

Cr-Commit-Position: refs/heads/master@{#32924}
parent 23384259
...@@ -2823,8 +2823,15 @@ void LCodeGen::DoHasInPrototypeChainAndBranch( ...@@ -2823,8 +2823,15 @@ void LCodeGen::DoHasInPrototypeChainAndBranch(
__ mov(object_map, FieldOperand(object, HeapObject::kMapOffset)); __ mov(object_map, FieldOperand(object, HeapObject::kMapOffset));
Label loop; Label loop;
__ bind(&loop); __ bind(&loop);
// Deoptimize if the object needs to be access checked.
__ test_b(FieldOperand(object_map, Map::kBitFieldOffset),
1 << Map::kIsAccessCheckNeeded);
DeoptimizeIf(not_zero, instr, Deoptimizer::kAccessCheck);
// Deoptimize for proxies.
__ CmpInstanceType(object_map, JS_PROXY_TYPE); __ CmpInstanceType(object_map, JS_PROXY_TYPE);
DeoptimizeIf(equal, instr, Deoptimizer::kProxy); DeoptimizeIf(equal, instr, Deoptimizer::kProxy);
__ mov(object_prototype, FieldOperand(object_map, Map::kPrototypeOffset)); __ mov(object_prototype, FieldOperand(object_map, Map::kPrototypeOffset));
__ cmp(object_prototype, prototype); __ cmp(object_prototype, prototype);
EmitTrueBranch(instr, equal); EmitTrueBranch(instr, equal);
......
...@@ -2280,19 +2280,22 @@ void InstanceOfStub::Generate(MacroAssembler* masm) { ...@@ -2280,19 +2280,22 @@ void InstanceOfStub::Generate(MacroAssembler* masm) {
__ mov(eax, isolate()->factory()->true_value()); __ mov(eax, isolate()->factory()->true_value());
__ bind(&loop); __ bind(&loop);
// Check if the object needs to be access checked.
__ test_b(FieldOperand(object_map, Map::kBitFieldOffset), __ test_b(FieldOperand(object_map, Map::kBitFieldOffset),
1 << Map::kIsAccessCheckNeeded); 1 << Map::kIsAccessCheckNeeded);
__ j(not_zero, &fast_runtime_fallback, Label::kNear); __ j(not_zero, &fast_runtime_fallback, Label::kNear);
// Check if the current object is a Proxy.
__ CmpInstanceType(object_map, JS_PROXY_TYPE); __ CmpInstanceType(object_map, JS_PROXY_TYPE);
__ j(equal, &fast_runtime_fallback, Label::kNear); __ j(equal, &fast_runtime_fallback, Label::kNear);
__ mov(object, FieldOperand(object_map, Map::kPrototypeOffset)); __ mov(object, FieldOperand(object_map, Map::kPrototypeOffset));
__ cmp(object, function_prototype); __ cmp(object, function_prototype);
__ j(equal, &done, Label::kNear); __ j(equal, &done, Label::kNear);
__ cmp(object, isolate()->factory()->null_value());
__ mov(object_map, FieldOperand(object, HeapObject::kMapOffset)); __ mov(object_map, FieldOperand(object, HeapObject::kMapOffset));
__ cmp(object, isolate()->factory()->null_value());
__ j(not_equal, &loop); __ j(not_equal, &loop);
__ mov(eax, isolate()->factory()->false_value()); __ mov(eax, isolate()->factory()->false_value());
__ bind(&done); __ bind(&done);
__ StoreRoot(eax, scratch, Heap::kInstanceofCacheAnswerRootIndex); __ StoreRoot(eax, scratch, Heap::kInstanceofCacheAnswerRootIndex);
__ ret(0); __ ret(0);
......
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