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_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 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1400 __ Push(edx); | 1400 __ Push(edx); |
1401 __ Move(eax, ebx); | 1401 __ Move(eax, ebx); |
1402 __ CallStub(&stub); | 1402 __ CallStub(&stub); |
1403 __ Move(ebx, eax); | 1403 __ Move(ebx, eax); |
1404 __ Pop(edx); | 1404 __ Pop(edx); |
1405 __ Pop(edi); | 1405 __ Pop(edi); |
1406 } | 1406 } |
1407 __ bind(&done_convert); | 1407 __ bind(&done_convert); |
1408 } | 1408 } |
1409 | 1409 |
1410 // 3. Allocate a JSValue wrapper for the string. | 1410 // 3. Check if original constructor and constructor differ. |
| 1411 Label new_object; |
| 1412 __ cmp(edx, edi); |
| 1413 __ j(not_equal, &new_object); |
| 1414 |
| 1415 // 4. Allocate a JSValue wrapper for the string. |
1411 { | 1416 { |
1412 // ----------- S t a t e ------------- | 1417 // ----------- S t a t e ------------- |
1413 // -- ebx : the first argument | 1418 // -- ebx : the first argument |
1414 // -- edi : constructor function | 1419 // -- edi : constructor function |
1415 // -- edx : original constructor | 1420 // -- edx : original constructor |
1416 // ----------------------------------- | 1421 // ----------------------------------- |
1417 | 1422 __ Allocate(JSValue::kSize, eax, ecx, no_reg, &new_object, TAG_OBJECT); |
1418 Label allocate, done_allocate, rt_call; | |
1419 | |
1420 // Fall back to runtime if the original constructor and constructor differ. | |
1421 __ cmp(edx, edi); | |
1422 __ j(not_equal, &rt_call); | |
1423 | |
1424 __ Allocate(JSValue::kSize, eax, ecx, no_reg, &allocate, TAG_OBJECT); | |
1425 __ bind(&done_allocate); | |
1426 | 1423 |
1427 // Initialize the JSValue in eax. | 1424 // Initialize the JSValue in eax. |
1428 __ LoadGlobalFunctionInitialMap(edi, ecx); | 1425 __ LoadGlobalFunctionInitialMap(edi, ecx); |
1429 __ mov(FieldOperand(eax, HeapObject::kMapOffset), ecx); | 1426 __ mov(FieldOperand(eax, HeapObject::kMapOffset), ecx); |
1430 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), | 1427 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), |
1431 masm->isolate()->factory()->empty_fixed_array()); | 1428 masm->isolate()->factory()->empty_fixed_array()); |
1432 __ mov(FieldOperand(eax, JSObject::kElementsOffset), | 1429 __ mov(FieldOperand(eax, JSObject::kElementsOffset), |
1433 masm->isolate()->factory()->empty_fixed_array()); | 1430 masm->isolate()->factory()->empty_fixed_array()); |
1434 __ mov(FieldOperand(eax, JSValue::kValueOffset), ebx); | 1431 __ mov(FieldOperand(eax, JSValue::kValueOffset), ebx); |
1435 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); | 1432 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); |
1436 __ Ret(); | 1433 __ Ret(); |
| 1434 } |
1437 | 1435 |
1438 // Fallback to the runtime to allocate in new space. | 1436 // 5. Fallback to the runtime to create new object. |
1439 __ bind(&allocate); | 1437 __ bind(&new_object); |
1440 { | 1438 { |
1441 FrameScope scope(masm, StackFrame::INTERNAL); | 1439 FrameScope scope(masm, StackFrame::INTERNAL); |
1442 __ Push(ebx); | 1440 __ Push(ebx); // the first argument |
1443 __ Push(edi); | 1441 __ Push(edi); // constructor function |
1444 __ Push(Smi::FromInt(JSValue::kSize)); | 1442 __ Push(edx); // original constructor |
1445 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); | 1443 __ CallRuntime(Runtime::kNewObject, 2); |
1446 __ Pop(edi); | 1444 __ Pop(FieldOperand(eax, JSValue::kValueOffset)); |
1447 __ Pop(ebx); | |
1448 } | |
1449 __ jmp(&done_allocate); | |
1450 | |
1451 // Fallback to the runtime to create new object. | |
1452 __ bind(&rt_call); | |
1453 { | |
1454 FrameScope scope(masm, StackFrame::INTERNAL); | |
1455 __ Push(ebx); | |
1456 __ Push(edi); | |
1457 __ Push(edi); // constructor function | |
1458 __ Push(edx); // original constructor | |
1459 __ CallRuntime(Runtime::kNewObject, 2); | |
1460 __ Pop(edi); | |
1461 __ Pop(ebx); | |
1462 } | |
1463 __ mov(FieldOperand(eax, JSValue::kValueOffset), ebx); | |
1464 __ Ret(); | |
1465 } | 1445 } |
| 1446 __ Ret(); |
1466 } | 1447 } |
1467 | 1448 |
1468 | 1449 |
1469 static void ArgumentsAdaptorStackCheck(MacroAssembler* masm, | 1450 static void ArgumentsAdaptorStackCheck(MacroAssembler* masm, |
1470 Label* stack_overflow) { | 1451 Label* stack_overflow) { |
1471 // ----------- S t a t e ------------- | 1452 // ----------- S t a t e ------------- |
1472 // -- eax : actual number of arguments | 1453 // -- eax : actual number of arguments |
1473 // -- ebx : expected number of arguments | 1454 // -- ebx : expected number of arguments |
1474 // -- edi : function (passed through to callee) | 1455 // -- edi : function (passed through to callee) |
1475 // ----------------------------------- | 1456 // ----------------------------------- |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1945 | 1926 |
1946 __ bind(&ok); | 1927 __ bind(&ok); |
1947 __ ret(0); | 1928 __ ret(0); |
1948 } | 1929 } |
1949 | 1930 |
1950 #undef __ | 1931 #undef __ |
1951 } // namespace internal | 1932 } // namespace internal |
1952 } // namespace v8 | 1933 } // namespace v8 |
1953 | 1934 |
1954 #endif // V8_TARGET_ARCH_IA32 | 1935 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |