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

Side by Side Diff: src/ia32/builtins-ia32.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/arm64/builtins-arm64.cc ('k') | src/mips/builtins-mips.cc » ('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_IA32 5 #if V8_TARGET_ARCH_IA32
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 2330 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 Register scratch0, Register scratch1, 2341 Register scratch0, Register scratch1,
2342 Label* receiver_check_failed) { 2342 Label* receiver_check_failed) {
2343 // If there is no signature, return the holder. 2343 // If there is no signature, return the holder.
2344 __ CompareRoot(FieldOperand(function_template_info, 2344 __ CompareRoot(FieldOperand(function_template_info,
2345 FunctionTemplateInfo::kSignatureOffset), 2345 FunctionTemplateInfo::kSignatureOffset),
2346 Heap::kUndefinedValueRootIndex); 2346 Heap::kUndefinedValueRootIndex);
2347 Label receiver_check_passed; 2347 Label receiver_check_passed;
2348 __ j(equal, &receiver_check_passed, Label::kNear); 2348 __ j(equal, &receiver_check_passed, Label::kNear);
2349 2349
2350 // Walk the prototype chain. 2350 // Walk the prototype chain.
2351 __ mov(scratch0, FieldOperand(receiver, HeapObject::kMapOffset));
2351 Label prototype_loop_start; 2352 Label prototype_loop_start;
2352 __ bind(&prototype_loop_start); 2353 __ bind(&prototype_loop_start);
2353 2354
2354 // End if receiver is null or if it's a hidden prototype.
2355 __ CompareRoot(receiver, Heap::kNullValueRootIndex);
2356 __ j(equal, receiver_check_failed, Label::kNear);
2357 __ mov(scratch0, FieldOperand(receiver, HeapObject::kMapOffset));
2358 __ test(FieldOperand(scratch0, Map::kBitField3Offset),
2359 Immediate(Map::IsHiddenPrototype::kMask));
2360 __ j(not_zero, receiver_check_failed, Label::kNear);
2361
2362 // Get the constructor, if any. 2355 // Get the constructor, if any.
2363 __ GetMapConstructor(scratch0, scratch0, scratch1); 2356 __ GetMapConstructor(scratch0, scratch0, scratch1);
2364 __ CmpInstanceType(scratch1, JS_FUNCTION_TYPE); 2357 __ CmpInstanceType(scratch1, JS_FUNCTION_TYPE);
2365 Label next_prototype; 2358 Label next_prototype;
2366 __ j(not_equal, &next_prototype, Label::kNear); 2359 __ j(not_equal, &next_prototype, Label::kNear);
2367 2360
2368 // Get the constructor's signature. 2361 // Get the constructor's signature.
2369 __ mov(scratch0, 2362 __ mov(scratch0,
2370 FieldOperand(scratch0, JSFunction::kSharedFunctionInfoOffset)); 2363 FieldOperand(scratch0, JSFunction::kSharedFunctionInfoOffset));
2371 __ mov(scratch0, 2364 __ mov(scratch0,
(...skipping 12 matching lines...) Expand all
2384 // in the chain. 2377 // in the chain.
2385 __ JumpIfSmi(scratch0, &next_prototype, Label::kNear); 2378 __ JumpIfSmi(scratch0, &next_prototype, Label::kNear);
2386 __ CmpObjectType(scratch0, FUNCTION_TEMPLATE_INFO_TYPE, scratch1); 2379 __ CmpObjectType(scratch0, FUNCTION_TEMPLATE_INFO_TYPE, scratch1);
2387 __ j(not_equal, &next_prototype, Label::kNear); 2380 __ j(not_equal, &next_prototype, Label::kNear);
2388 2381
2389 // Otherwise load the parent function template and iterate. 2382 // Otherwise load the parent function template and iterate.
2390 __ mov(scratch0, 2383 __ mov(scratch0,
2391 FieldOperand(scratch0, FunctionTemplateInfo::kParentTemplateOffset)); 2384 FieldOperand(scratch0, FunctionTemplateInfo::kParentTemplateOffset));
2392 __ jmp(&function_template_loop, Label::kNear); 2385 __ jmp(&function_template_loop, Label::kNear);
2393 2386
2394 // Load the next prototype and iterate. 2387 // Load the next prototype.
2395 __ bind(&next_prototype); 2388 __ bind(&next_prototype);
2396 __ mov(receiver, FieldOperand(receiver, HeapObject::kMapOffset)); 2389 __ mov(receiver, FieldOperand(receiver, HeapObject::kMapOffset));
2397 __ mov(receiver, FieldOperand(receiver, Map::kPrototypeOffset)); 2390 __ mov(receiver, FieldOperand(receiver, Map::kPrototypeOffset));
2391 // End if the prototype is null or not hidden.
2392 __ CompareRoot(receiver, Heap::kNullValueRootIndex);
2393 __ j(equal, receiver_check_failed);
2394 __ mov(scratch0, FieldOperand(receiver, HeapObject::kMapOffset));
2395 __ test(FieldOperand(scratch0, Map::kBitField3Offset),
2396 Immediate(Map::IsHiddenPrototype::kMask));
2397 __ j(zero, receiver_check_failed);
2398 // Iterate.
2398 __ jmp(&prototype_loop_start, Label::kNear); 2399 __ jmp(&prototype_loop_start, Label::kNear);
2399 2400
2400 __ bind(&receiver_check_passed); 2401 __ bind(&receiver_check_passed);
2401 } 2402 }
2402 2403
2403 2404
2404 void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) { 2405 void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) {
2405 // ----------- S t a t e ------------- 2406 // ----------- S t a t e -------------
2406 // -- eax : number of arguments (not including the receiver) 2407 // -- eax : number of arguments (not including the receiver)
2407 // -- edi : callee 2408 // -- edi : callee
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2498 2499
2499 __ bind(&ok); 2500 __ bind(&ok);
2500 __ ret(0); 2501 __ ret(0);
2501 } 2502 }
2502 2503
2503 #undef __ 2504 #undef __
2504 } // namespace internal 2505 } // namespace internal
2505 } // namespace v8 2506 } // namespace v8
2506 2507
2507 #endif // V8_TARGET_ARCH_IA32 2508 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm64/builtins-arm64.cc ('k') | src/mips/builtins-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698