| OLD | NEW |
| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); | 111 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); |
| 112 GenerateTailCallToReturnedCode(masm); | 112 GenerateTailCallToReturnedCode(masm); |
| 113 | 113 |
| 114 __ bind(&ok); | 114 __ bind(&ok); |
| 115 GenerateTailCallToSharedCode(masm); | 115 GenerateTailCallToSharedCode(masm); |
| 116 } | 116 } |
| 117 | 117 |
| 118 | 118 |
| 119 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 119 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
| 120 bool is_api_function, | 120 bool is_api_function, |
| 121 bool create_implicit_receiver) { | 121 bool create_implicit_receiver, |
| 122 bool check_derived_construct) { |
| 122 // ----------- S t a t e ------------- | 123 // ----------- S t a t e ------------- |
| 123 // -- eax: number of arguments | 124 // -- eax: number of arguments |
| 124 // -- edi: constructor function | 125 // -- edi: constructor function |
| 125 // -- ebx: allocation site or undefined | 126 // -- ebx: allocation site or undefined |
| 126 // -- edx: new target | 127 // -- edx: new target |
| 127 // ----------------------------------- | 128 // ----------------------------------- |
| 128 | 129 |
| 129 // Enter a construct frame. | 130 // Enter a construct frame. |
| 130 { | 131 { |
| 131 FrameScope scope(masm, StackFrame::CONSTRUCT); | 132 FrameScope scope(masm, StackFrame::CONSTRUCT); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 // arguments count is stored below the receiver. | 353 // arguments count is stored below the receiver. |
| 353 __ bind(&exit); | 354 __ bind(&exit); |
| 354 __ mov(ebx, Operand(esp, 1 * kPointerSize)); | 355 __ mov(ebx, Operand(esp, 1 * kPointerSize)); |
| 355 } else { | 356 } else { |
| 356 __ mov(ebx, Operand(esp, 0)); | 357 __ mov(ebx, Operand(esp, 0)); |
| 357 } | 358 } |
| 358 | 359 |
| 359 // Leave construct frame. | 360 // Leave construct frame. |
| 360 } | 361 } |
| 361 | 362 |
| 363 // ES6 9.2.2. Step 13+ |
| 364 // Check that the result is not a Smi, indicating that the constructor result |
| 365 // from a derived class is neither undefined nor an Object. |
| 366 if (check_derived_construct) { |
| 367 Label dont_throw; |
| 368 __ JumpIfNotSmi(eax, &dont_throw); |
| 369 { |
| 370 FrameScope scope(masm, StackFrame::INTERNAL); |
| 371 __ CallRuntime(Runtime::kThrowDerivedConstructorReturnedNonObject); |
| 372 } |
| 373 __ bind(&dont_throw); |
| 374 } |
| 375 |
| 362 // Remove caller arguments from the stack and return. | 376 // Remove caller arguments from the stack and return. |
| 363 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); | 377 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); |
| 364 __ pop(ecx); | 378 __ pop(ecx); |
| 365 __ lea(esp, Operand(esp, ebx, times_2, 1 * kPointerSize)); // 1 ~ receiver | 379 __ lea(esp, Operand(esp, ebx, times_2, 1 * kPointerSize)); // 1 ~ receiver |
| 366 __ push(ecx); | 380 __ push(ecx); |
| 367 if (create_implicit_receiver) { | 381 if (create_implicit_receiver) { |
| 368 __ IncrementCounter(masm->isolate()->counters()->constructed_objects(), 1); | 382 __ IncrementCounter(masm->isolate()->counters()->constructed_objects(), 1); |
| 369 } | 383 } |
| 370 __ ret(0); | 384 __ ret(0); |
| 371 } | 385 } |
| 372 | 386 |
| 373 | 387 |
| 374 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { | 388 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { |
| 375 Generate_JSConstructStubHelper(masm, false, true); | 389 Generate_JSConstructStubHelper(masm, false, true, false); |
| 376 } | 390 } |
| 377 | 391 |
| 378 | 392 |
| 379 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { | 393 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { |
| 380 Generate_JSConstructStubHelper(masm, true, true); | 394 Generate_JSConstructStubHelper(masm, true, true, false); |
| 381 } | 395 } |
| 382 | 396 |
| 383 | 397 |
| 384 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { | 398 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { |
| 385 Generate_JSConstructStubHelper(masm, false, false); | 399 Generate_JSConstructStubHelper(masm, false, false, false); |
| 386 } | 400 } |
| 387 | 401 |
| 388 | 402 |
| 403 void Builtins::Generate_JSBuiltinsConstructStubForDerived( |
| 404 MacroAssembler* masm) { |
| 405 Generate_JSConstructStubHelper(masm, false, false, true); |
| 406 } |
| 407 |
| 408 |
| 389 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { | 409 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { |
| 390 FrameScope scope(masm, StackFrame::INTERNAL); | 410 FrameScope scope(masm, StackFrame::INTERNAL); |
| 391 __ push(edi); | 411 __ push(edi); |
| 392 __ CallRuntime(Runtime::kThrowConstructedNonConstructable); | 412 __ CallRuntime(Runtime::kThrowConstructedNonConstructable); |
| 393 } | 413 } |
| 394 | 414 |
| 395 | 415 |
| 396 enum IsTagged { kEaxIsSmiTagged, kEaxIsUntaggedInt }; | 416 enum IsTagged { kEaxIsSmiTagged, kEaxIsUntaggedInt }; |
| 397 | 417 |
| 398 | 418 |
| (...skipping 2107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2506 | 2526 |
| 2507 __ bind(&ok); | 2527 __ bind(&ok); |
| 2508 __ ret(0); | 2528 __ ret(0); |
| 2509 } | 2529 } |
| 2510 | 2530 |
| 2511 #undef __ | 2531 #undef __ |
| 2512 } // namespace internal | 2532 } // namespace internal |
| 2513 } // namespace v8 | 2533 } // namespace v8 |
| 2514 | 2534 |
| 2515 #endif // V8_TARGET_ARCH_X87 | 2535 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |