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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 273 |
274 // Allocate the new receiver object using the runtime call. | 274 // Allocate the new receiver object using the runtime call. |
275 // edx: original constructor | 275 // edx: original constructor |
276 __ bind(&rt_call); | 276 __ bind(&rt_call); |
277 int offset = kPointerSize; | 277 int offset = kPointerSize; |
278 | 278 |
279 // Must restore esi (context) and edi (constructor) before calling | 279 // Must restore esi (context) and edi (constructor) before calling |
280 // runtime. | 280 // runtime. |
281 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 281 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
282 __ mov(edi, Operand(esp, offset)); | 282 __ mov(edi, Operand(esp, offset)); |
283 __ push(edi); // argument 2/1: constructor function | 283 __ push(edi); // constructor function |
284 __ push(edx); // argument 3/2: original constructor | 284 __ push(edx); // original constructor |
285 __ CallRuntime(Runtime::kNewObject, 2); | 285 __ CallRuntime(Runtime::kNewObject, 2); |
286 __ mov(ebx, eax); // store result in ebx | 286 __ mov(ebx, eax); // store result in ebx |
287 | 287 |
288 // New object allocated. | 288 // New object allocated. |
289 // ebx: newly allocated object | 289 // ebx: newly allocated object |
290 __ bind(&allocated); | 290 __ bind(&allocated); |
291 | 291 |
292 // Restore the parameters. | 292 // Restore the parameters. |
293 __ pop(edx); // new.target | 293 __ pop(edx); // new.target |
294 __ pop(edi); // Constructor function. | 294 __ pop(edi); // Constructor function. |
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1356 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1); | 1356 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1); |
1357 } | 1357 } |
1358 } | 1358 } |
1359 | 1359 |
1360 | 1360 |
1361 // static | 1361 // static |
1362 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { | 1362 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { |
1363 // ----------- S t a t e ------------- | 1363 // ----------- S t a t e ------------- |
1364 // -- eax : number of arguments | 1364 // -- eax : number of arguments |
1365 // -- edi : constructor function | 1365 // -- edi : constructor function |
| 1366 // -- edx : original constructor |
1366 // -- esp[0] : return address | 1367 // -- esp[0] : return address |
1367 // -- esp[(argc - n) * 4] : arg[n] (zero-based) | 1368 // -- esp[(argc - n) * 4] : arg[n] (zero-based) |
1368 // -- esp[(argc + 1) * 4] : receiver | 1369 // -- esp[(argc + 1) * 4] : receiver |
1369 // ----------------------------------- | 1370 // ----------------------------------- |
1370 | 1371 |
1371 // 1. Load the first argument into ebx and get rid of the rest (including the | 1372 // 1. Load the first argument into ebx and get rid of the rest (including the |
1372 // receiver). | 1373 // receiver). |
1373 { | 1374 { |
1374 Label no_arguments, done; | 1375 Label no_arguments, done; |
1375 __ test(eax, eax); | 1376 __ test(eax, eax); |
1376 __ j(zero, &no_arguments, Label::kNear); | 1377 __ j(zero, &no_arguments, Label::kNear); |
1377 __ mov(ebx, Operand(esp, eax, times_pointer_size, 0)); | 1378 __ mov(ebx, Operand(esp, eax, times_pointer_size, 0)); |
1378 __ jmp(&done, Label::kNear); | 1379 __ jmp(&done, Label::kNear); |
1379 __ bind(&no_arguments); | 1380 __ bind(&no_arguments); |
1380 __ LoadRoot(ebx, Heap::kempty_stringRootIndex); | 1381 __ LoadRoot(ebx, Heap::kempty_stringRootIndex); |
1381 __ bind(&done); | 1382 __ bind(&done); |
1382 __ PopReturnAddressTo(ecx); | 1383 __ PopReturnAddressTo(ecx); |
1383 __ lea(esp, Operand(esp, eax, times_pointer_size, kPointerSize)); | 1384 __ lea(esp, Operand(esp, eax, times_pointer_size, kPointerSize)); |
1384 __ PushReturnAddressFrom(ecx); | 1385 __ PushReturnAddressFrom(ecx); |
1385 } | 1386 } |
1386 | 1387 |
1387 // 2. Make sure ebx is a string. | 1388 // 2. Make sure ebx is a string. |
1388 { | 1389 { |
1389 Label convert, done_convert; | 1390 Label convert, done_convert; |
1390 __ JumpIfSmi(ebx, &convert, Label::kNear); | 1391 __ JumpIfSmi(ebx, &convert, Label::kNear); |
1391 __ CmpObjectType(ebx, FIRST_NONSTRING_TYPE, edx); | 1392 __ CmpObjectType(ebx, FIRST_NONSTRING_TYPE, ecx); |
1392 __ j(below, &done_convert); | 1393 __ j(below, &done_convert); |
1393 __ bind(&convert); | 1394 __ bind(&convert); |
1394 { | 1395 { |
1395 FrameScope scope(masm, StackFrame::INTERNAL); | 1396 FrameScope scope(masm, StackFrame::INTERNAL); |
1396 ToStringStub stub(masm->isolate()); | 1397 ToStringStub stub(masm->isolate()); |
1397 __ Push(edi); | 1398 __ Push(edi); |
| 1399 __ Push(edx); |
1398 __ Move(eax, ebx); | 1400 __ Move(eax, ebx); |
1399 __ CallStub(&stub); | 1401 __ CallStub(&stub); |
1400 __ Move(ebx, eax); | 1402 __ Move(ebx, eax); |
| 1403 __ Pop(edx); |
1401 __ Pop(edi); | 1404 __ Pop(edi); |
1402 } | 1405 } |
1403 __ bind(&done_convert); | 1406 __ bind(&done_convert); |
1404 } | 1407 } |
1405 | 1408 |
1406 // 3. Allocate a JSValue wrapper for the string. | 1409 // 3. Allocate a JSValue wrapper for the string. |
1407 { | 1410 { |
1408 // ----------- S t a t e ------------- | 1411 // ----------- S t a t e ------------- |
1409 // -- ebx : the first argument | 1412 // -- ebx : the first argument |
1410 // -- edi : constructor function | 1413 // -- edi : constructor function |
| 1414 // -- edx : original constructor |
1411 // ----------------------------------- | 1415 // ----------------------------------- |
1412 | 1416 |
1413 Label allocate, done_allocate; | 1417 Label allocate, done_allocate, rt_call; |
| 1418 |
| 1419 // Fall back to runtime if the original constructor and constructor differ. |
| 1420 __ cmp(edx, edi); |
| 1421 __ j(not_equal, &rt_call); |
| 1422 |
1414 __ Allocate(JSValue::kSize, eax, ecx, no_reg, &allocate, TAG_OBJECT); | 1423 __ Allocate(JSValue::kSize, eax, ecx, no_reg, &allocate, TAG_OBJECT); |
1415 __ bind(&done_allocate); | 1424 __ bind(&done_allocate); |
1416 | 1425 |
1417 // Initialize the JSValue in eax. | 1426 // Initialize the JSValue in eax. |
1418 __ LoadGlobalFunctionInitialMap(edi, ecx); | 1427 __ LoadGlobalFunctionInitialMap(edi, ecx); |
1419 __ mov(FieldOperand(eax, HeapObject::kMapOffset), ecx); | 1428 __ mov(FieldOperand(eax, HeapObject::kMapOffset), ecx); |
1420 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), | 1429 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), |
1421 masm->isolate()->factory()->empty_fixed_array()); | 1430 masm->isolate()->factory()->empty_fixed_array()); |
1422 __ mov(FieldOperand(eax, JSObject::kElementsOffset), | 1431 __ mov(FieldOperand(eax, JSObject::kElementsOffset), |
1423 masm->isolate()->factory()->empty_fixed_array()); | 1432 masm->isolate()->factory()->empty_fixed_array()); |
1424 __ mov(FieldOperand(eax, JSValue::kValueOffset), ebx); | 1433 __ mov(FieldOperand(eax, JSValue::kValueOffset), ebx); |
1425 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); | 1434 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); |
1426 __ Ret(); | 1435 __ Ret(); |
1427 | 1436 |
1428 // Fallback to the runtime to allocate in new space. | 1437 // Fallback to the runtime to allocate in new space. |
1429 __ bind(&allocate); | 1438 __ bind(&allocate); |
1430 { | 1439 { |
1431 FrameScope scope(masm, StackFrame::INTERNAL); | 1440 FrameScope scope(masm, StackFrame::INTERNAL); |
1432 __ Push(ebx); | 1441 __ Push(ebx); |
1433 __ Push(edi); | 1442 __ Push(edi); |
1434 __ Push(Smi::FromInt(JSValue::kSize)); | 1443 __ Push(Smi::FromInt(JSValue::kSize)); |
1435 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); | 1444 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); |
1436 __ Pop(edi); | 1445 __ Pop(edi); |
1437 __ Pop(ebx); | 1446 __ Pop(ebx); |
1438 } | 1447 } |
1439 __ jmp(&done_allocate); | 1448 __ jmp(&done_allocate); |
| 1449 |
| 1450 // Fallback to the runtime to create new object. |
| 1451 __ bind(&rt_call); |
| 1452 { |
| 1453 FrameScope scope(masm, StackFrame::INTERNAL); |
| 1454 __ Push(ebx); |
| 1455 __ Push(edi); |
| 1456 __ Push(edi); // constructor function |
| 1457 __ Push(edx); // original constructor |
| 1458 __ CallRuntime(Runtime::kNewObject, 2); |
| 1459 __ Pop(edi); |
| 1460 __ Pop(ebx); |
| 1461 } |
| 1462 __ mov(FieldOperand(eax, JSValue::kValueOffset), ebx); |
| 1463 __ Ret(); |
1440 } | 1464 } |
1441 } | 1465 } |
1442 | 1466 |
1443 | 1467 |
1444 static void ArgumentsAdaptorStackCheck(MacroAssembler* masm, | 1468 static void ArgumentsAdaptorStackCheck(MacroAssembler* masm, |
1445 Label* stack_overflow) { | 1469 Label* stack_overflow) { |
1446 // ----------- S t a t e ------------- | 1470 // ----------- S t a t e ------------- |
1447 // -- eax : actual number of arguments | 1471 // -- eax : actual number of arguments |
1448 // -- ebx : expected number of arguments | 1472 // -- ebx : expected number of arguments |
1449 // -- edi : function (passed through to callee) | 1473 // -- edi : function (passed through to callee) |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1900 | 1924 |
1901 __ bind(&ok); | 1925 __ bind(&ok); |
1902 __ ret(0); | 1926 __ ret(0); |
1903 } | 1927 } |
1904 | 1928 |
1905 #undef __ | 1929 #undef __ |
1906 } // namespace internal | 1930 } // namespace internal |
1907 } // namespace v8 | 1931 } // namespace v8 |
1908 | 1932 |
1909 #endif // V8_TARGET_ARCH_IA32 | 1933 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |