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

Side by Side Diff: src/x87/builtins-x87.cc

Issue 1576423003: Fix the receiver check in the HandleFastApiCall builtin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 4 years, 11 months 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 unified diff | Download patch
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_X87 5 #if V8_TARGET_ARCH_X87
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 2337 matching lines...) Expand 10 before | Expand all | Expand 10 after
2348 Register scratch0, Register scratch1, 2348 Register scratch0, Register scratch1,
2349 Label* receiver_check_failed) { 2349 Label* receiver_check_failed) {
2350 // If there is no signature, return the holder. 2350 // If there is no signature, return the holder.
2351 __ CompareRoot(FieldOperand(function_template_info, 2351 __ CompareRoot(FieldOperand(function_template_info,
2352 FunctionTemplateInfo::kSignatureOffset), 2352 FunctionTemplateInfo::kSignatureOffset),
2353 Heap::kUndefinedValueRootIndex); 2353 Heap::kUndefinedValueRootIndex);
2354 Label receiver_check_passed; 2354 Label receiver_check_passed;
2355 __ j(equal, &receiver_check_passed, Label::kNear); 2355 __ j(equal, &receiver_check_passed, Label::kNear);
2356 2356
2357 // Walk the prototype chain. 2357 // Walk the prototype chain.
2358 __ mov(scratch0, FieldOperand(receiver, HeapObject::kMapOffset));
2358 Label prototype_loop_start; 2359 Label prototype_loop_start;
2359 __ bind(&prototype_loop_start); 2360 __ bind(&prototype_loop_start);
2360 2361
2361 // End if receiver is null or if it's a hidden prototype.
2362 __ CompareRoot(receiver, Heap::kNullValueRootIndex);
2363 __ j(equal, receiver_check_failed, Label::kNear);
2364 __ mov(scratch0, FieldOperand(receiver, HeapObject::kMapOffset));
2365 __ test(FieldOperand(scratch0, Map::kBitField3Offset),
2366 Immediate(Map::IsHiddenPrototype::kMask));
2367 __ j(not_zero, receiver_check_failed, Label::kNear);
2368
2369 // Get the constructor, if any. 2362 // Get the constructor, if any.
2370 __ GetMapConstructor(scratch0, scratch0, scratch1); 2363 __ GetMapConstructor(scratch0, scratch0, scratch1);
2371 __ CmpInstanceType(scratch1, JS_FUNCTION_TYPE); 2364 __ CmpInstanceType(scratch1, JS_FUNCTION_TYPE);
2372 Label next_prototype; 2365 Label next_prototype;
2373 __ j(not_equal, &next_prototype, Label::kNear); 2366 __ j(not_equal, &next_prototype, Label::kNear);
2374 2367
2375 // Get the constructor's signature. 2368 // Get the constructor's signature.
2376 __ mov(scratch0, 2369 __ mov(scratch0,
2377 FieldOperand(scratch0, JSFunction::kSharedFunctionInfoOffset)); 2370 FieldOperand(scratch0, JSFunction::kSharedFunctionInfoOffset));
2378 __ mov(scratch0, 2371 __ mov(scratch0,
(...skipping 12 matching lines...) Expand all
2391 // in the chain. 2384 // in the chain.
2392 __ JumpIfSmi(scratch0, &next_prototype, Label::kNear); 2385 __ JumpIfSmi(scratch0, &next_prototype, Label::kNear);
2393 __ CmpObjectType(scratch0, FUNCTION_TEMPLATE_INFO_TYPE, scratch1); 2386 __ CmpObjectType(scratch0, FUNCTION_TEMPLATE_INFO_TYPE, scratch1);
2394 __ j(not_equal, &next_prototype, Label::kNear); 2387 __ j(not_equal, &next_prototype, Label::kNear);
2395 2388
2396 // Otherwise load the parent function template and iterate. 2389 // Otherwise load the parent function template and iterate.
2397 __ mov(scratch0, 2390 __ mov(scratch0,
2398 FieldOperand(scratch0, FunctionTemplateInfo::kParentTemplateOffset)); 2391 FieldOperand(scratch0, FunctionTemplateInfo::kParentTemplateOffset));
2399 __ jmp(&function_template_loop, Label::kNear); 2392 __ jmp(&function_template_loop, Label::kNear);
2400 2393
2401 // Load the next prototype and iterate. 2394 // Load the next prototype.
2402 __ bind(&next_prototype); 2395 __ bind(&next_prototype);
2403 __ mov(receiver, FieldOperand(receiver, HeapObject::kMapOffset)); 2396 __ mov(receiver, FieldOperand(receiver, HeapObject::kMapOffset));
2404 __ mov(receiver, FieldOperand(receiver, Map::kPrototypeOffset)); 2397 __ mov(receiver, FieldOperand(receiver, Map::kPrototypeOffset));
2398 // End if the prototype is null or not hidden.
2399 __ CompareRoot(receiver, Heap::kNullValueRootIndex);
2400 __ j(equal, receiver_check_failed);
2401 __ mov(scratch0, FieldOperand(receiver, HeapObject::kMapOffset));
2402 __ test(FieldOperand(scratch0, Map::kBitField3Offset),
2403 Immediate(Map::IsHiddenPrototype::kMask));
2404 __ j(zero, receiver_check_failed);
2405 // Iterate.
2405 __ jmp(&prototype_loop_start, Label::kNear); 2406 __ jmp(&prototype_loop_start, Label::kNear);
2406 2407
2407 __ bind(&receiver_check_passed); 2408 __ bind(&receiver_check_passed);
2408 } 2409 }
2409 2410
2410 2411
2411 void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) { 2412 void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) {
2412 // ----------- S t a t e ------------- 2413 // ----------- S t a t e -------------
2413 // -- eax : number of arguments (not including the receiver) 2414 // -- eax : number of arguments (not including the receiver)
2414 // -- edi : callee 2415 // -- edi : callee
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2505 2506
2506 __ bind(&ok); 2507 __ bind(&ok);
2507 __ ret(0); 2508 __ ret(0);
2508 } 2509 }
2509 2510
2510 #undef __ 2511 #undef __
2511 } // namespace internal 2512 } // namespace internal
2512 } // namespace v8 2513 } // namespace v8
2513 2514
2514 #endif // V8_TARGET_ARCH_X87 2515 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698