| 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-stubs.h" | 7 #include "src/code-stubs.h" | 
| 8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" | 
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" | 
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" | 
| (...skipping 3306 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3317 | 3317 | 
| 3318   Label fast_elements_case; | 3318   Label fast_elements_case; | 
| 3319   __ cmp(ecx, Immediate(FAST_ELEMENTS)); | 3319   __ cmp(ecx, Immediate(FAST_ELEMENTS)); | 
| 3320   __ j(equal, &fast_elements_case); | 3320   __ j(equal, &fast_elements_case); | 
| 3321   GenerateCase(masm, FAST_HOLEY_ELEMENTS); | 3321   GenerateCase(masm, FAST_HOLEY_ELEMENTS); | 
| 3322 | 3322 | 
| 3323   __ bind(&fast_elements_case); | 3323   __ bind(&fast_elements_case); | 
| 3324   GenerateCase(masm, FAST_ELEMENTS); | 3324   GenerateCase(masm, FAST_ELEMENTS); | 
| 3325 } | 3325 } | 
| 3326 | 3326 | 
| 3327 |  | 
| 3328 void FastNewObjectStub::Generate(MacroAssembler* masm) { |  | 
| 3329   // ----------- S t a t e ------------- |  | 
| 3330   //  -- edi    : target |  | 
| 3331   //  -- edx    : new target |  | 
| 3332   //  -- esi    : context |  | 
| 3333   //  -- esp[0] : return address |  | 
| 3334   // ----------------------------------- |  | 
| 3335   __ AssertFunction(edi); |  | 
| 3336   __ AssertReceiver(edx); |  | 
| 3337 |  | 
| 3338   // Verify that the new target is a JSFunction. |  | 
| 3339   Label new_object; |  | 
| 3340   __ CmpObjectType(edx, JS_FUNCTION_TYPE, ebx); |  | 
| 3341   __ j(not_equal, &new_object); |  | 
| 3342 |  | 
| 3343   // Load the initial map and verify that it's in fact a map. |  | 
| 3344   __ mov(ecx, FieldOperand(edx, JSFunction::kPrototypeOrInitialMapOffset)); |  | 
| 3345   __ JumpIfSmi(ecx, &new_object); |  | 
| 3346   __ CmpObjectType(ecx, MAP_TYPE, ebx); |  | 
| 3347   __ j(not_equal, &new_object); |  | 
| 3348 |  | 
| 3349   // Fall back to runtime if the target differs from the new target's |  | 
| 3350   // initial map constructor. |  | 
| 3351   __ cmp(edi, FieldOperand(ecx, Map::kConstructorOrBackPointerOffset)); |  | 
| 3352   __ j(not_equal, &new_object); |  | 
| 3353 |  | 
| 3354   // Allocate the JSObject on the heap. |  | 
| 3355   Label allocate, done_allocate; |  | 
| 3356   __ movzx_b(ebx, FieldOperand(ecx, Map::kInstanceSizeOffset)); |  | 
| 3357   __ lea(ebx, Operand(ebx, times_pointer_size, 0)); |  | 
| 3358   __ Allocate(ebx, eax, edi, no_reg, &allocate, NO_ALLOCATION_FLAGS); |  | 
| 3359   __ bind(&done_allocate); |  | 
| 3360 |  | 
| 3361   // Initialize the JSObject fields. |  | 
| 3362   __ mov(FieldOperand(eax, JSObject::kMapOffset), ecx); |  | 
| 3363   __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), |  | 
| 3364          masm->isolate()->factory()->empty_fixed_array()); |  | 
| 3365   __ mov(FieldOperand(eax, JSObject::kElementsOffset), |  | 
| 3366          masm->isolate()->factory()->empty_fixed_array()); |  | 
| 3367   STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); |  | 
| 3368   __ lea(ebx, FieldOperand(eax, JSObject::kHeaderSize)); |  | 
| 3369 |  | 
| 3370   // ----------- S t a t e ------------- |  | 
| 3371   //  -- eax    : result (tagged) |  | 
| 3372   //  -- ebx    : result fields (untagged) |  | 
| 3373   //  -- edi    : result end (untagged) |  | 
| 3374   //  -- ecx    : initial map |  | 
| 3375   //  -- esi    : context |  | 
| 3376   //  -- esp[0] : return address |  | 
| 3377   // ----------------------------------- |  | 
| 3378 |  | 
| 3379   // Perform in-object slack tracking if requested. |  | 
| 3380   Label slack_tracking; |  | 
| 3381   STATIC_ASSERT(Map::kNoSlackTracking == 0); |  | 
| 3382   __ test(FieldOperand(ecx, Map::kBitField3Offset), |  | 
| 3383           Immediate(Map::ConstructionCounter::kMask)); |  | 
| 3384   __ j(not_zero, &slack_tracking, Label::kNear); |  | 
| 3385   { |  | 
| 3386     // Initialize all in-object fields with undefined. |  | 
| 3387     __ LoadRoot(edx, Heap::kUndefinedValueRootIndex); |  | 
| 3388     __ InitializeFieldsWithFiller(ebx, edi, edx); |  | 
| 3389     __ Ret(); |  | 
| 3390   } |  | 
| 3391   __ bind(&slack_tracking); |  | 
| 3392   { |  | 
| 3393     // Decrease generous allocation count. |  | 
| 3394     STATIC_ASSERT(Map::ConstructionCounter::kNext == 32); |  | 
| 3395     __ sub(FieldOperand(ecx, Map::kBitField3Offset), |  | 
| 3396            Immediate(1 << Map::ConstructionCounter::kShift)); |  | 
| 3397 |  | 
| 3398     // Initialize the in-object fields with undefined. |  | 
| 3399     __ movzx_b(edx, FieldOperand(ecx, Map::kUnusedPropertyFieldsOffset)); |  | 
| 3400     __ neg(edx); |  | 
| 3401     __ lea(edx, Operand(edi, edx, times_pointer_size, 0)); |  | 
| 3402     __ LoadRoot(edi, Heap::kUndefinedValueRootIndex); |  | 
| 3403     __ InitializeFieldsWithFiller(ebx, edx, edi); |  | 
| 3404 |  | 
| 3405     // Initialize the remaining (reserved) fields with one pointer filler map. |  | 
| 3406     __ movzx_b(edx, FieldOperand(ecx, Map::kUnusedPropertyFieldsOffset)); |  | 
| 3407     __ lea(edx, Operand(ebx, edx, times_pointer_size, 0)); |  | 
| 3408     __ LoadRoot(edi, Heap::kOnePointerFillerMapRootIndex); |  | 
| 3409     __ InitializeFieldsWithFiller(ebx, edx, edi); |  | 
| 3410 |  | 
| 3411     // Check if we can finalize the instance size. |  | 
| 3412     Label finalize; |  | 
| 3413     STATIC_ASSERT(Map::kSlackTrackingCounterEnd == 1); |  | 
| 3414     __ test(FieldOperand(ecx, Map::kBitField3Offset), |  | 
| 3415             Immediate(Map::ConstructionCounter::kMask)); |  | 
| 3416     __ j(zero, &finalize, Label::kNear); |  | 
| 3417     __ Ret(); |  | 
| 3418 |  | 
| 3419     // Finalize the instance size. |  | 
| 3420     __ bind(&finalize); |  | 
| 3421     { |  | 
| 3422       FrameScope scope(masm, StackFrame::INTERNAL); |  | 
| 3423       __ Push(eax); |  | 
| 3424       __ Push(ecx); |  | 
| 3425       __ CallRuntime(Runtime::kFinalizeInstanceSize); |  | 
| 3426       __ Pop(eax); |  | 
| 3427     } |  | 
| 3428     __ Ret(); |  | 
| 3429   } |  | 
| 3430 |  | 
| 3431   // Fall back to %AllocateInNewSpace. |  | 
| 3432   __ bind(&allocate); |  | 
| 3433   { |  | 
| 3434     FrameScope scope(masm, StackFrame::INTERNAL); |  | 
| 3435     __ SmiTag(ebx); |  | 
| 3436     __ Push(ecx); |  | 
| 3437     __ Push(ebx); |  | 
| 3438     __ CallRuntime(Runtime::kAllocateInNewSpace); |  | 
| 3439     __ Pop(ecx); |  | 
| 3440   } |  | 
| 3441   __ movzx_b(ebx, FieldOperand(ecx, Map::kInstanceSizeOffset)); |  | 
| 3442   __ lea(edi, Operand(eax, ebx, times_pointer_size, 0)); |  | 
| 3443   STATIC_ASSERT(kHeapObjectTag == 1); |  | 
| 3444   __ dec(edi); |  | 
| 3445   __ jmp(&done_allocate); |  | 
| 3446 |  | 
| 3447   // Fall back to %NewObject. |  | 
| 3448   __ bind(&new_object); |  | 
| 3449   __ PopReturnAddressTo(ecx); |  | 
| 3450   __ Push(edi); |  | 
| 3451   __ Push(edx); |  | 
| 3452   __ PushReturnAddressFrom(ecx); |  | 
| 3453   __ TailCallRuntime(Runtime::kNewObject); |  | 
| 3454 } |  | 
| 3455 |  | 
| 3456 |  | 
| 3457 void FastNewRestParameterStub::Generate(MacroAssembler* masm) { | 3327 void FastNewRestParameterStub::Generate(MacroAssembler* masm) { | 
| 3458   // ----------- S t a t e ------------- | 3328   // ----------- S t a t e ------------- | 
| 3459   //  -- edi    : function | 3329   //  -- edi    : function | 
| 3460   //  -- esi    : context | 3330   //  -- esi    : context | 
| 3461   //  -- ebp    : frame pointer | 3331   //  -- ebp    : frame pointer | 
| 3462   //  -- esp[0] : return address | 3332   //  -- esp[0] : return address | 
| 3463   // ----------------------------------- | 3333   // ----------------------------------- | 
| 3464   __ AssertFunction(edi); | 3334   __ AssertFunction(edi); | 
| 3465 | 3335 | 
| 3466   // Make edx point to the JavaScript frame. | 3336   // Make edx point to the JavaScript frame. | 
| (...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4384                            kStackUnwindSpace, nullptr, return_value_operand, | 4254                            kStackUnwindSpace, nullptr, return_value_operand, | 
| 4385                            NULL); | 4255                            NULL); | 
| 4386 } | 4256 } | 
| 4387 | 4257 | 
| 4388 #undef __ | 4258 #undef __ | 
| 4389 | 4259 | 
| 4390 }  // namespace internal | 4260 }  // namespace internal | 
| 4391 }  // namespace v8 | 4261 }  // namespace v8 | 
| 4392 | 4262 | 
| 4393 #endif  // V8_TARGET_ARCH_IA32 | 4263 #endif  // V8_TARGET_ARCH_IA32 | 
| OLD | NEW | 
|---|