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

Side by Side Diff: src/arm/code-stubs-arm.cc

Issue 1418623007: [runtime] Fix ES6 9.2.1 [[Call]] when encountering a classConstructor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: mips Created 5 years, 1 month 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
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_ARM 5 #if V8_TARGET_ARCH_ARM
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 2362 matching lines...) Expand 10 before | Expand all | Expand 10 after
2373 __ b(&done); 2373 __ b(&done);
2374 2374
2375 __ bind(&not_array_function); 2375 __ bind(&not_array_function);
2376 CreateWeakCellStub weak_cell_stub(masm->isolate()); 2376 CreateWeakCellStub weak_cell_stub(masm->isolate());
2377 CallStubInRecordCallTarget(masm, &weak_cell_stub, is_super); 2377 CallStubInRecordCallTarget(masm, &weak_cell_stub, is_super);
2378 __ bind(&done); 2378 __ bind(&done);
2379 } 2379 }
2380 2380
2381 2381
2382 static void EmitContinueIfStrictOrNative(MacroAssembler* masm, Label* cont) { 2382 static void EmitContinueIfStrictOrNative(MacroAssembler* masm, Label* cont) {
2383 // ----------- S t a t e -------------
2384 // -- r1 : the function to call
2385 // -- r3 : the function's shared function info
2386 // -----------------------------------
2383 // Do not transform the receiver for strict mode functions. 2387 // Do not transform the receiver for strict mode functions.
2384 __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
2385 __ ldr(r4, FieldMemOperand(r3, SharedFunctionInfo::kCompilerHintsOffset)); 2388 __ ldr(r4, FieldMemOperand(r3, SharedFunctionInfo::kCompilerHintsOffset));
2386 __ tst(r4, Operand(1 << (SharedFunctionInfo::kStrictModeFunction + 2389 __ tst(r4, Operand(1 << (SharedFunctionInfo::kStrictModeFunction +
2387 kSmiTagSize))); 2390 kSmiTagSize)));
2388 __ b(ne, cont); 2391 __ b(ne, cont);
2389 2392
2390 // Do not transform the receiver for native (Compilerhints already in r3). 2393 // Do not transform the receiver for native (Compilerhints already in r3).
2391 __ tst(r4, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize))); 2394 __ tst(r4, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize)));
2392 __ b(ne, cont); 2395 __ b(ne, cont);
2393 } 2396 }
2394 2397
(...skipping 11 matching lines...) Expand all
2406 __ mov(r0, r3); 2409 __ mov(r0, r3);
2407 ToObjectStub stub(masm->isolate()); 2410 ToObjectStub stub(masm->isolate());
2408 __ CallStub(&stub); 2411 __ CallStub(&stub);
2409 __ pop(r1); 2412 __ pop(r1);
2410 } 2413 }
2411 __ str(r0, MemOperand(sp, argc * kPointerSize)); 2414 __ str(r0, MemOperand(sp, argc * kPointerSize));
2412 __ jmp(cont); 2415 __ jmp(cont);
2413 } 2416 }
2414 2417
2415 2418
2419 static void EmitClassConstructorCallCheck(MacroAssembler* masm) {
2420 // ----------- S t a t e -------------
2421 // -- r1 : the function to call
2422 // -- r3 : the function's shared function info
2423 // -----------------------------------
2424 // ClassConstructor Check: ES6 section 9.2.1 [[Call]]
2425 Label non_class_constructor;
2426 // Check whether the current function is a classConstructor This only works
2427 // since kClassConstructor is more than 1 bit away from the byte boundary in
2428 // CompilerHints (note that compiler_hints is stored as smi on 32bit
2429 // architectures)
2430 STATIC_ASSERT((FunctionKind::kClassConstructor << kSmiTagSize) <
2431 (1 << kBitsPerByte));
2432 __ ldrb(r4, FieldMemOperand(r3, SharedFunctionInfo::kFunctionKindByteOffset));
2433 // Left-shift to account for smi storage in 32bits.
2434 __ tst(r4, Operand(FunctionKind::kClassConstructor << kSmiTagSize));
2435 __ b(eq, &non_class_constructor);
2436 // If we call a classConstructor Function throw a TypeError
2437 // indirectly via the CallFunction builtin.
2438 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET);
2439 __ bind(&non_class_constructor);
2440 }
2441
2442
2416 static void CallFunctionNoFeedback(MacroAssembler* masm, 2443 static void CallFunctionNoFeedback(MacroAssembler* masm,
2417 int argc, bool needs_checks, 2444 int argc, bool needs_checks,
2418 bool call_as_method) { 2445 bool call_as_method) {
2419 // r1 : the function to call 2446 // r1 : the function to call
2420 Label slow, wrap, cont; 2447 Label slow, wrap, cont;
2421 2448
2422 if (needs_checks) { 2449 if (needs_checks) {
2423 // Check that the function is really a JavaScript function. 2450 // Check that the function is really a JavaScript function.
2424 // r1: pushed function (to be verified) 2451 // r1: pushed function (to be verified)
2425 __ JumpIfSmi(r1, &slow); 2452 __ JumpIfSmi(r1, &slow);
2426 2453
2427 // Goto slow case if we do not have a function. 2454 // Goto slow case if we do not have a function.
2428 __ CompareObjectType(r1, r4, r4, JS_FUNCTION_TYPE); 2455 __ CompareObjectType(r1, r4, r4, JS_FUNCTION_TYPE);
2429 __ b(ne, &slow); 2456 __ b(ne, &slow);
2430 } 2457 }
2431 2458
2459 __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
2460 EmitClassConstructorCallCheck(masm);
2461
2432 // Fast-case: Invoke the function now. 2462 // Fast-case: Invoke the function now.
2433 // r1: pushed function 2463 // r1: pushed function
2434 ParameterCount actual(argc); 2464 ParameterCount actual(argc);
2435 2465
2436 if (call_as_method) { 2466 if (call_as_method) {
2437 if (needs_checks) { 2467 if (needs_checks) {
2438 EmitContinueIfStrictOrNative(masm, &cont); 2468 EmitContinueIfStrictOrNative(masm, &cont);
2439 } 2469 }
2440 2470
2441 // Compute the receiver in sloppy mode. 2471 // Compute the receiver in sloppy mode.
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
2587 __ JumpIfSmi(r1, &extra_checks_or_miss); 2617 __ JumpIfSmi(r1, &extra_checks_or_miss);
2588 2618
2589 // Increment the call count for monomorphic function calls. 2619 // Increment the call count for monomorphic function calls.
2590 __ add(r2, r2, Operand::PointerOffsetFromSmiKey(r3)); 2620 __ add(r2, r2, Operand::PointerOffsetFromSmiKey(r3));
2591 __ add(r2, r2, Operand(FixedArray::kHeaderSize + kPointerSize)); 2621 __ add(r2, r2, Operand(FixedArray::kHeaderSize + kPointerSize));
2592 __ ldr(r3, FieldMemOperand(r2, 0)); 2622 __ ldr(r3, FieldMemOperand(r2, 0));
2593 __ add(r3, r3, Operand(Smi::FromInt(CallICNexus::kCallCountIncrement))); 2623 __ add(r3, r3, Operand(Smi::FromInt(CallICNexus::kCallCountIncrement)));
2594 __ str(r3, FieldMemOperand(r2, 0)); 2624 __ str(r3, FieldMemOperand(r2, 0));
2595 2625
2596 __ bind(&have_js_function); 2626 __ bind(&have_js_function);
2627
2628 __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
2629 EmitClassConstructorCallCheck(masm);
2630
2597 if (CallAsMethod()) { 2631 if (CallAsMethod()) {
2598 EmitContinueIfStrictOrNative(masm, &cont); 2632 EmitContinueIfStrictOrNative(masm, &cont);
2599 // Compute the receiver in sloppy mode. 2633 // Compute the receiver in sloppy mode.
2600 __ ldr(r3, MemOperand(sp, argc * kPointerSize)); 2634 __ ldr(r3, MemOperand(sp, argc * kPointerSize));
2601 2635
2602 __ JumpIfSmi(r3, &wrap); 2636 __ JumpIfSmi(r3, &wrap);
2603 __ CompareObjectType(r3, r4, r4, FIRST_SPEC_OBJECT_TYPE); 2637 __ CompareObjectType(r3, r4, r4, FIRST_SPEC_OBJECT_TYPE);
2604 __ b(lt, &wrap); 2638 __ b(lt, &wrap);
2605 2639
2606 __ bind(&cont); 2640 __ bind(&cont);
(...skipping 2955 matching lines...) Expand 10 before | Expand all | Expand 10 after
5562 MemOperand(fp, 6 * kPointerSize), NULL); 5596 MemOperand(fp, 6 * kPointerSize), NULL);
5563 } 5597 }
5564 5598
5565 5599
5566 #undef __ 5600 #undef __
5567 5601
5568 } // namespace internal 5602 } // namespace internal
5569 } // namespace v8 5603 } // namespace v8
5570 5604
5571 #endif // V8_TARGET_ARCH_ARM 5605 #endif // V8_TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698