OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 361 |
362 GenerateFastCloneShallowArrayCommon(masm, length_, mode, &slow_case); | 362 GenerateFastCloneShallowArrayCommon(masm, length_, mode, &slow_case); |
363 // Return and remove the on-stack parameters. | 363 // Return and remove the on-stack parameters. |
364 __ ret(3 * kPointerSize); | 364 __ ret(3 * kPointerSize); |
365 | 365 |
366 __ bind(&slow_case); | 366 __ bind(&slow_case); |
367 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); | 367 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); |
368 } | 368 } |
369 | 369 |
370 | 370 |
| 371 void FastCloneShallowObjectStub::Generate(MacroAssembler* masm) { |
| 372 // Stack layout on entry: |
| 373 // |
| 374 // [esp + kPointerSize]: object literal flags. |
| 375 // [esp + (2 * kPointerSize)]: constant properties. |
| 376 // [esp + (3 * kPointerSize)]: literal index. |
| 377 // [esp + (4 * kPointerSize)]: literals array. |
| 378 |
| 379 // Load boilerplate object into ecx and check if we need to create a |
| 380 // boilerplate. |
| 381 Label slow_case; |
| 382 __ mov(ecx, Operand(esp, 4 * kPointerSize)); |
| 383 __ mov(eax, Operand(esp, 3 * kPointerSize)); |
| 384 STATIC_ASSERT(kPointerSize == 4); |
| 385 STATIC_ASSERT(kSmiTagSize == 1); |
| 386 STATIC_ASSERT(kSmiTag == 0); |
| 387 __ mov(ecx, FieldOperand(ecx, eax, times_half_pointer_size, |
| 388 FixedArray::kHeaderSize)); |
| 389 Factory* factory = masm->isolate()->factory(); |
| 390 __ cmp(ecx, factory->undefined_value()); |
| 391 __ j(equal, &slow_case); |
| 392 |
| 393 // Check that the boilerplate contains only fast properties and we can |
| 394 // statically determine the instance size. |
| 395 int size = JSObject::kHeaderSize + length_ * kPointerSize; |
| 396 __ mov(eax, FieldOperand(ecx, HeapObject::kMapOffset)); |
| 397 __ movzx_b(eax, FieldOperand(eax, Map::kInstanceSizeOffset)); |
| 398 __ cmp(eax, Immediate(size >> kPointerSizeLog2)); |
| 399 __ j(not_equal, &slow_case); |
| 400 |
| 401 // Allocate the JS object and copy header together with all in-object |
| 402 // properties from the boilerplate. |
| 403 __ AllocateInNewSpace(size, eax, ebx, edx, &slow_case, TAG_OBJECT); |
| 404 for (int i = 0; i < size; i += kPointerSize) { |
| 405 __ mov(ebx, FieldOperand(ecx, i)); |
| 406 __ mov(FieldOperand(eax, i), ebx); |
| 407 } |
| 408 |
| 409 // Return and remove the on-stack parameters. |
| 410 __ ret(4 * kPointerSize); |
| 411 |
| 412 __ bind(&slow_case); |
| 413 __ TailCallRuntime(Runtime::kCreateObjectLiteralShallow, 4, 1); |
| 414 } |
| 415 |
| 416 |
371 // The stub expects its argument on the stack and returns its result in tos_: | 417 // The stub expects its argument on the stack and returns its result in tos_: |
372 // zero for false, and a non-zero value for true. | 418 // zero for false, and a non-zero value for true. |
373 void ToBooleanStub::Generate(MacroAssembler* masm) { | 419 void ToBooleanStub::Generate(MacroAssembler* masm) { |
374 // This stub overrides SometimesSetsUpAFrame() to return false. That means | 420 // This stub overrides SometimesSetsUpAFrame() to return false. That means |
375 // we cannot call anything that could cause a GC from this stub. | 421 // we cannot call anything that could cause a GC from this stub. |
376 Label patch; | 422 Label patch; |
377 Factory* factory = masm->isolate()->factory(); | 423 Factory* factory = masm->isolate()->factory(); |
378 const Register argument = eax; | 424 const Register argument = eax; |
379 const Register map = edx; | 425 const Register map = edx; |
380 | 426 |
(...skipping 6697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7078 false); | 7124 false); |
7079 __ pop(edx); | 7125 __ pop(edx); |
7080 __ ret(0); | 7126 __ ret(0); |
7081 } | 7127 } |
7082 | 7128 |
7083 #undef __ | 7129 #undef __ |
7084 | 7130 |
7085 } } // namespace v8::internal | 7131 } } // namespace v8::internal |
7086 | 7132 |
7087 #endif // V8_TARGET_ARCH_IA32 | 7133 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |