OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 3222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3233 // Check to see whether there are any break points in the function code. If | 3233 // Check to see whether there are any break points in the function code. If |
3234 // there are jump to the generic constructor stub which calls the actual | 3234 // there are jump to the generic constructor stub which calls the actual |
3235 // code for the function thereby hitting the break points. | 3235 // code for the function thereby hitting the break points. |
3236 __ movq(rbx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | 3236 __ movq(rbx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
3237 __ movq(rbx, FieldOperand(rbx, SharedFunctionInfo::kDebugInfoOffset)); | 3237 __ movq(rbx, FieldOperand(rbx, SharedFunctionInfo::kDebugInfoOffset)); |
3238 __ cmpq(rbx, r8); | 3238 __ cmpq(rbx, r8); |
3239 __ j(not_equal, &generic_stub_call); | 3239 __ j(not_equal, &generic_stub_call); |
3240 #endif | 3240 #endif |
3241 | 3241 |
3242 // Load the initial map and verify that it is in fact a map. | 3242 // Load the initial map and verify that it is in fact a map. |
| 3243 // rdi: constructor |
3243 __ movq(rbx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset)); | 3244 __ movq(rbx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset)); |
3244 // Will both indicate a NULL and a Smi. | 3245 // Will both indicate a NULL and a Smi. |
3245 STATIC_ASSERT(kSmiTag == 0); | 3246 STATIC_ASSERT(kSmiTag == 0); |
3246 __ JumpIfSmi(rbx, &generic_stub_call); | 3247 __ JumpIfSmi(rbx, &generic_stub_call); |
3247 __ CmpObjectType(rbx, MAP_TYPE, rcx); | 3248 __ CmpObjectType(rbx, MAP_TYPE, rcx); |
3248 __ j(not_equal, &generic_stub_call); | 3249 __ j(not_equal, &generic_stub_call); |
3249 | 3250 |
3250 #ifdef DEBUG | 3251 #ifdef DEBUG |
3251 // Cannot construct functions this way. | 3252 // Cannot construct functions this way. |
3252 // rdi: constructor | |
3253 // rbx: initial map | 3253 // rbx: initial map |
3254 __ CmpInstanceType(rbx, JS_FUNCTION_TYPE); | 3254 __ CmpInstanceType(rbx, JS_FUNCTION_TYPE); |
3255 __ Assert(not_equal, "Function constructed by construct stub."); | 3255 __ Check(not_equal, "Function constructed by construct stub."); |
3256 #endif | 3256 #endif |
3257 | 3257 |
3258 // Now allocate the JSObject in new space. | 3258 // Now allocate the JSObject in new space. |
3259 // rdi: constructor | |
3260 // rbx: initial map | 3259 // rbx: initial map |
| 3260 ASSERT(function->has_initial_map()); |
| 3261 int instance_size = function->initial_map()->instance_size(); |
| 3262 #ifdef DEBUG |
3261 __ movzxbq(rcx, FieldOperand(rbx, Map::kInstanceSizeOffset)); | 3263 __ movzxbq(rcx, FieldOperand(rbx, Map::kInstanceSizeOffset)); |
3262 __ shl(rcx, Immediate(kPointerSizeLog2)); | 3264 __ shl(rcx, Immediate(kPointerSizeLog2)); |
3263 __ AllocateInNewSpace(rcx, rdx, rcx, no_reg, | 3265 __ cmpq(rcx, Immediate(instance_size)); |
| 3266 __ Check(equal, "Instance size of initial map changed."); |
| 3267 #endif |
| 3268 __ AllocateInNewSpace(instance_size, rdx, rcx, no_reg, |
3264 &generic_stub_call, NO_ALLOCATION_FLAGS); | 3269 &generic_stub_call, NO_ALLOCATION_FLAGS); |
3265 | 3270 |
3266 // Allocated the JSObject, now initialize the fields and add the heap tag. | 3271 // Allocated the JSObject, now initialize the fields and add the heap tag. |
3267 // rbx: initial map | 3272 // rbx: initial map |
3268 // rdx: JSObject (untagged) | 3273 // rdx: JSObject (untagged) |
3269 __ movq(Operand(rdx, JSObject::kMapOffset), rbx); | 3274 __ movq(Operand(rdx, JSObject::kMapOffset), rbx); |
3270 __ Move(rbx, factory()->empty_fixed_array()); | 3275 __ Move(rbx, factory()->empty_fixed_array()); |
3271 __ movq(Operand(rdx, JSObject::kPropertiesOffset), rbx); | 3276 __ movq(Operand(rdx, JSObject::kPropertiesOffset), rbx); |
3272 __ movq(Operand(rdx, JSObject::kElementsOffset), rbx); | 3277 __ movq(Operand(rdx, JSObject::kElementsOffset), rbx); |
3273 | 3278 |
(...skipping 25 matching lines...) Expand all Loading... |
3299 // Store value in the property. | 3304 // Store value in the property. |
3300 __ movq(Operand(r9, i * kPointerSize), rbx); | 3305 __ movq(Operand(r9, i * kPointerSize), rbx); |
3301 } else { | 3306 } else { |
3302 // Set the property to the constant value. | 3307 // Set the property to the constant value. |
3303 Handle<Object> constant(shared->GetThisPropertyAssignmentConstant(i)); | 3308 Handle<Object> constant(shared->GetThisPropertyAssignmentConstant(i)); |
3304 __ Move(Operand(r9, i * kPointerSize), constant); | 3309 __ Move(Operand(r9, i * kPointerSize), constant); |
3305 } | 3310 } |
3306 } | 3311 } |
3307 | 3312 |
3308 // Fill the unused in-object property fields with undefined. | 3313 // Fill the unused in-object property fields with undefined. |
3309 ASSERT(function->has_initial_map()); | |
3310 for (int i = shared->this_property_assignments_count(); | 3314 for (int i = shared->this_property_assignments_count(); |
3311 i < function->initial_map()->inobject_properties(); | 3315 i < function->initial_map()->inobject_properties(); |
3312 i++) { | 3316 i++) { |
3313 __ movq(Operand(r9, i * kPointerSize), r8); | 3317 __ movq(Operand(r9, i * kPointerSize), r8); |
3314 } | 3318 } |
3315 | 3319 |
3316 // rax: argc | 3320 // rax: argc |
3317 // rdx: JSObject (untagged) | 3321 // rdx: JSObject (untagged) |
3318 // Move argc to rbx and the JSObject to return to rax and tag it. | 3322 // Move argc to rbx and the JSObject to return to rax and tag it. |
3319 __ movq(rbx, rax); | 3323 __ movq(rbx, rax); |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4096 __ jmp(ic_slow, RelocInfo::CODE_TARGET); | 4100 __ jmp(ic_slow, RelocInfo::CODE_TARGET); |
4097 } | 4101 } |
4098 } | 4102 } |
4099 | 4103 |
4100 | 4104 |
4101 #undef __ | 4105 #undef __ |
4102 | 4106 |
4103 } } // namespace v8::internal | 4107 } } // namespace v8::internal |
4104 | 4108 |
4105 #endif // V8_TARGET_ARCH_X64 | 4109 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |