| 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 3253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3264 VisitForStackValue(args->at(1)); | 3264 VisitForStackValue(args->at(1)); |
| 3265 VisitForStackValue(args->at(2)); | 3265 VisitForStackValue(args->at(2)); |
| 3266 __ CallRuntime(Runtime::kLog, 2); | 3266 __ CallRuntime(Runtime::kLog, 2); |
| 3267 } | 3267 } |
| 3268 // Finally, we're expected to leave a value on the top of the stack. | 3268 // Finally, we're expected to leave a value on the top of the stack. |
| 3269 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); | 3269 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); |
| 3270 context()->Plug(rax); | 3270 context()->Plug(rax); |
| 3271 } | 3271 } |
| 3272 | 3272 |
| 3273 | 3273 |
| 3274 void FullCodeGenerator::EmitRandomHeapNumber(CallRuntime* expr) { | |
| 3275 ASSERT(expr->arguments()->length() == 0); | |
| 3276 | |
| 3277 Label slow_allocate_heapnumber; | |
| 3278 Label heapnumber_allocated; | |
| 3279 | |
| 3280 __ AllocateHeapNumber(rbx, rcx, &slow_allocate_heapnumber); | |
| 3281 __ jmp(&heapnumber_allocated); | |
| 3282 | |
| 3283 __ bind(&slow_allocate_heapnumber); | |
| 3284 // Allocate a heap number. | |
| 3285 __ CallRuntime(Runtime::kNumberAlloc, 0); | |
| 3286 __ movq(rbx, rax); | |
| 3287 | |
| 3288 __ bind(&heapnumber_allocated); | |
| 3289 | |
| 3290 // Return a random uint32 number in rax. | |
| 3291 // The fresh HeapNumber is in rbx, which is callee-save on both x64 ABIs. | |
| 3292 __ PrepareCallCFunction(1); | |
| 3293 __ movq(arg_reg_1, | |
| 3294 ContextOperand(context_register(), Context::GLOBAL_OBJECT_INDEX)); | |
| 3295 __ movq(arg_reg_1, | |
| 3296 FieldOperand(arg_reg_1, GlobalObject::kNativeContextOffset)); | |
| 3297 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1); | |
| 3298 | |
| 3299 // Convert 32 random bits in rax to 0.(32 random bits) in a double | |
| 3300 // by computing: | |
| 3301 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). | |
| 3302 __ movl(rcx, Immediate(0x49800000)); // 1.0 x 2^20 as single. | |
| 3303 __ movd(xmm1, rcx); | |
| 3304 __ movd(xmm0, rax); | |
| 3305 __ cvtss2sd(xmm1, xmm1); | |
| 3306 __ xorps(xmm0, xmm1); | |
| 3307 __ subsd(xmm0, xmm1); | |
| 3308 __ movsd(FieldOperand(rbx, HeapNumber::kValueOffset), xmm0); | |
| 3309 | |
| 3310 __ movq(rax, rbx); | |
| 3311 context()->Plug(rax); | |
| 3312 } | |
| 3313 | |
| 3314 | |
| 3315 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { | 3274 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { |
| 3316 // Load the arguments on the stack and call the stub. | 3275 // Load the arguments on the stack and call the stub. |
| 3317 SubStringStub stub; | 3276 SubStringStub stub; |
| 3318 ZoneList<Expression*>* args = expr->arguments(); | 3277 ZoneList<Expression*>* args = expr->arguments(); |
| 3319 ASSERT(args->length() == 3); | 3278 ASSERT(args->length() == 3); |
| 3320 VisitForStackValue(args->at(0)); | 3279 VisitForStackValue(args->at(0)); |
| 3321 VisitForStackValue(args->at(1)); | 3280 VisitForStackValue(args->at(1)); |
| 3322 VisitForStackValue(args->at(2)); | 3281 VisitForStackValue(args->at(2)); |
| 3323 __ CallStub(&stub); | 3282 __ CallStub(&stub); |
| 3324 context()->Plug(rax); | 3283 context()->Plug(rax); |
| (...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4937 | 4896 |
| 4938 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4897 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 4939 Assembler::target_address_at(call_target_address)); | 4898 Assembler::target_address_at(call_target_address)); |
| 4940 return OSR_AFTER_STACK_CHECK; | 4899 return OSR_AFTER_STACK_CHECK; |
| 4941 } | 4900 } |
| 4942 | 4901 |
| 4943 | 4902 |
| 4944 } } // namespace v8::internal | 4903 } } // namespace v8::internal |
| 4945 | 4904 |
| 4946 #endif // V8_TARGET_ARCH_X64 | 4905 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |