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