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-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 3112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3123 | 3123 |
3124 Label fast_elements_case; | 3124 Label fast_elements_case; |
3125 __ cmp(ecx, Immediate(FAST_ELEMENTS)); | 3125 __ cmp(ecx, Immediate(FAST_ELEMENTS)); |
3126 __ j(equal, &fast_elements_case); | 3126 __ j(equal, &fast_elements_case); |
3127 GenerateCase(masm, FAST_HOLEY_ELEMENTS); | 3127 GenerateCase(masm, FAST_HOLEY_ELEMENTS); |
3128 | 3128 |
3129 __ bind(&fast_elements_case); | 3129 __ bind(&fast_elements_case); |
3130 GenerateCase(masm, FAST_ELEMENTS); | 3130 GenerateCase(masm, FAST_ELEMENTS); |
3131 } | 3131 } |
3132 | 3132 |
3133 void FastNewObjectStub::Generate(MacroAssembler* masm) { | |
3134 // ----------- S t a t e ------------- | |
3135 // -- edi : target | |
3136 // -- edx : new target | |
3137 // -- esi : context | |
3138 // -- esp[0] : return address | |
3139 // ----------------------------------- | |
3140 __ AssertFunction(edi); | |
3141 __ AssertReceiver(edx); | |
3142 | |
3143 // Verify that the new target is a JSFunction. | |
3144 Label new_object; | |
3145 __ CmpObjectType(edx, JS_FUNCTION_TYPE, ebx); | |
3146 __ j(not_equal, &new_object); | |
3147 | |
3148 // Load the initial map and verify that it's in fact a map. | |
3149 __ mov(ecx, FieldOperand(edx, JSFunction::kPrototypeOrInitialMapOffset)); | |
3150 __ JumpIfSmi(ecx, &new_object); | |
3151 __ CmpObjectType(ecx, MAP_TYPE, ebx); | |
3152 __ j(not_equal, &new_object); | |
3153 | |
3154 // Fall back to runtime if the target differs from the new target's | |
3155 // initial map constructor. | |
3156 __ cmp(edi, FieldOperand(ecx, Map::kConstructorOrBackPointerOffset)); | |
3157 __ j(not_equal, &new_object); | |
3158 | |
3159 // Allocate the JSObject on the heap. | |
3160 Label allocate, done_allocate; | |
3161 __ movzx_b(ebx, FieldOperand(ecx, Map::kInstanceSizeOffset)); | |
3162 __ lea(ebx, Operand(ebx, times_pointer_size, 0)); | |
3163 __ Allocate(ebx, eax, edi, no_reg, &allocate, NO_ALLOCATION_FLAGS); | |
3164 __ bind(&done_allocate); | |
3165 | |
3166 // Initialize the JSObject fields. | |
3167 __ mov(FieldOperand(eax, JSObject::kMapOffset), ecx); | |
3168 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), | |
3169 masm->isolate()->factory()->empty_fixed_array()); | |
3170 __ mov(FieldOperand(eax, JSObject::kElementsOffset), | |
3171 masm->isolate()->factory()->empty_fixed_array()); | |
3172 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); | |
3173 __ lea(ebx, FieldOperand(eax, JSObject::kHeaderSize)); | |
3174 | |
3175 // ----------- S t a t e ------------- | |
3176 // -- eax : result (tagged) | |
3177 // -- ebx : result fields (untagged) | |
3178 // -- edi : result end (untagged) | |
3179 // -- ecx : initial map | |
3180 // -- esi : context | |
3181 // -- esp[0] : return address | |
3182 // ----------------------------------- | |
3183 | |
3184 // Perform in-object slack tracking if requested. | |
3185 Label slack_tracking; | |
3186 STATIC_ASSERT(Map::kNoSlackTracking == 0); | |
3187 __ test(FieldOperand(ecx, Map::kBitField3Offset), | |
3188 Immediate(Map::ConstructionCounter::kMask)); | |
3189 __ j(not_zero, &slack_tracking, Label::kNear); | |
3190 { | |
3191 // Initialize all in-object fields with undefined. | |
3192 __ LoadRoot(edx, Heap::kUndefinedValueRootIndex); | |
3193 __ InitializeFieldsWithFiller(ebx, edi, edx); | |
3194 __ Ret(); | |
3195 } | |
3196 __ bind(&slack_tracking); | |
3197 { | |
3198 // Decrease generous allocation count. | |
3199 STATIC_ASSERT(Map::ConstructionCounter::kNext == 32); | |
3200 __ sub(FieldOperand(ecx, Map::kBitField3Offset), | |
3201 Immediate(1 << Map::ConstructionCounter::kShift)); | |
3202 | |
3203 // Initialize the in-object fields with undefined. | |
3204 __ movzx_b(edx, FieldOperand(ecx, Map::kUnusedPropertyFieldsOffset)); | |
3205 __ neg(edx); | |
3206 __ lea(edx, Operand(edi, edx, times_pointer_size, 0)); | |
3207 __ LoadRoot(edi, Heap::kUndefinedValueRootIndex); | |
3208 __ InitializeFieldsWithFiller(ebx, edx, edi); | |
3209 | |
3210 // Initialize the remaining (reserved) fields with one pointer filler map. | |
3211 __ movzx_b(edx, FieldOperand(ecx, Map::kUnusedPropertyFieldsOffset)); | |
3212 __ lea(edx, Operand(ebx, edx, times_pointer_size, 0)); | |
3213 __ LoadRoot(edi, Heap::kOnePointerFillerMapRootIndex); | |
3214 __ InitializeFieldsWithFiller(ebx, edx, edi); | |
3215 | |
3216 // Check if we can finalize the instance size. | |
3217 Label finalize; | |
3218 STATIC_ASSERT(Map::kSlackTrackingCounterEnd == 1); | |
3219 __ test(FieldOperand(ecx, Map::kBitField3Offset), | |
3220 Immediate(Map::ConstructionCounter::kMask)); | |
3221 __ j(zero, &finalize, Label::kNear); | |
3222 __ Ret(); | |
3223 | |
3224 // Finalize the instance size. | |
3225 __ bind(&finalize); | |
3226 { | |
3227 FrameScope scope(masm, StackFrame::INTERNAL); | |
3228 __ Push(eax); | |
3229 __ Push(ecx); | |
3230 __ CallRuntime(Runtime::kFinalizeInstanceSize); | |
3231 __ Pop(eax); | |
3232 } | |
3233 __ Ret(); | |
3234 } | |
3235 | |
3236 // Fall back to %AllocateInNewSpace. | |
3237 __ bind(&allocate); | |
3238 { | |
3239 FrameScope scope(masm, StackFrame::INTERNAL); | |
3240 __ SmiTag(ebx); | |
3241 __ Push(ecx); | |
3242 __ Push(ebx); | |
3243 __ CallRuntime(Runtime::kAllocateInNewSpace); | |
3244 __ Pop(ecx); | |
3245 } | |
3246 __ movzx_b(ebx, FieldOperand(ecx, Map::kInstanceSizeOffset)); | |
3247 __ lea(edi, Operand(eax, ebx, times_pointer_size, 0)); | |
3248 STATIC_ASSERT(kHeapObjectTag == 1); | |
3249 __ dec(edi); | |
3250 __ jmp(&done_allocate); | |
3251 | |
3252 // Fall back to %NewObject. | |
3253 __ bind(&new_object); | |
3254 __ PopReturnAddressTo(ecx); | |
3255 __ Push(edi); | |
3256 __ Push(edx); | |
3257 __ PushReturnAddressFrom(ecx); | |
3258 __ TailCallRuntime(Runtime::kNewObject); | |
3259 } | |
3260 | |
3261 void FastNewRestParameterStub::Generate(MacroAssembler* masm) { | 3133 void FastNewRestParameterStub::Generate(MacroAssembler* masm) { |
3262 // ----------- S t a t e ------------- | 3134 // ----------- S t a t e ------------- |
3263 // -- edi : function | 3135 // -- edi : function |
3264 // -- esi : context | 3136 // -- esi : context |
3265 // -- ebp : frame pointer | 3137 // -- ebp : frame pointer |
3266 // -- esp[0] : return address | 3138 // -- esp[0] : return address |
3267 // ----------------------------------- | 3139 // ----------------------------------- |
3268 __ AssertFunction(edi); | 3140 __ AssertFunction(edi); |
3269 | 3141 |
3270 // Make edx point to the JavaScript frame. | 3142 // Make edx point to the JavaScript frame. |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4185 kStackUnwindSpace, nullptr, return_value_operand, | 4057 kStackUnwindSpace, nullptr, return_value_operand, |
4186 NULL); | 4058 NULL); |
4187 } | 4059 } |
4188 | 4060 |
4189 #undef __ | 4061 #undef __ |
4190 | 4062 |
4191 } // namespace internal | 4063 } // namespace internal |
4192 } // namespace v8 | 4064 } // namespace v8 |
4193 | 4065 |
4194 #endif // V8_TARGET_ARCH_X87 | 4066 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |