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 3278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3289 VisitForStackValue(args->at(1)); | 3289 VisitForStackValue(args->at(1)); |
3290 VisitForStackValue(args->at(2)); | 3290 VisitForStackValue(args->at(2)); |
3291 __ CallRuntime(Runtime::kLog, 2); | 3291 __ CallRuntime(Runtime::kLog, 2); |
3292 } | 3292 } |
3293 // Finally, we're expected to leave a value on the top of the stack. | 3293 // Finally, we're expected to leave a value on the top of the stack. |
3294 __ mov(eax, isolate()->factory()->undefined_value()); | 3294 __ mov(eax, isolate()->factory()->undefined_value()); |
3295 context()->Plug(eax); | 3295 context()->Plug(eax); |
3296 } | 3296 } |
3297 | 3297 |
3298 | 3298 |
| 3299 void FullCodeGenerator::EmitRandomHeapNumber(CallRuntime* expr) { |
| 3300 ASSERT(expr->arguments()->length() == 0); |
| 3301 |
| 3302 Label slow_allocate_heapnumber; |
| 3303 Label heapnumber_allocated; |
| 3304 |
| 3305 __ AllocateHeapNumber(edi, ebx, ecx, &slow_allocate_heapnumber); |
| 3306 __ jmp(&heapnumber_allocated); |
| 3307 |
| 3308 __ bind(&slow_allocate_heapnumber); |
| 3309 // Allocate a heap number. |
| 3310 __ CallRuntime(Runtime::kNumberAlloc, 0); |
| 3311 __ mov(edi, eax); |
| 3312 |
| 3313 __ bind(&heapnumber_allocated); |
| 3314 |
| 3315 __ PrepareCallCFunction(1, ebx); |
| 3316 __ mov(eax, ContextOperand(context_register(), Context::GLOBAL_OBJECT_INDEX)); |
| 3317 __ mov(eax, FieldOperand(eax, GlobalObject::kNativeContextOffset)); |
| 3318 __ mov(Operand(esp, 0), eax); |
| 3319 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1); |
| 3320 |
| 3321 // Convert 32 random bits in eax to 0.(32 random bits) in a double |
| 3322 // by computing: |
| 3323 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). |
| 3324 // This is implemented on both SSE2 and FPU. |
| 3325 if (CpuFeatures::IsSupported(SSE2)) { |
| 3326 CpuFeatureScope fscope(masm(), SSE2); |
| 3327 __ mov(ebx, Immediate(0x49800000)); // 1.0 x 2^20 as single. |
| 3328 __ movd(xmm1, ebx); |
| 3329 __ movd(xmm0, eax); |
| 3330 __ cvtss2sd(xmm1, xmm1); |
| 3331 __ xorps(xmm0, xmm1); |
| 3332 __ subsd(xmm0, xmm1); |
| 3333 __ movsd(FieldOperand(edi, HeapNumber::kValueOffset), xmm0); |
| 3334 } else { |
| 3335 // 0x4130000000000000 is 1.0 x 2^20 as a double. |
| 3336 __ mov(FieldOperand(edi, HeapNumber::kExponentOffset), |
| 3337 Immediate(0x41300000)); |
| 3338 __ mov(FieldOperand(edi, HeapNumber::kMantissaOffset), eax); |
| 3339 __ fld_d(FieldOperand(edi, HeapNumber::kValueOffset)); |
| 3340 __ mov(FieldOperand(edi, HeapNumber::kMantissaOffset), Immediate(0)); |
| 3341 __ fld_d(FieldOperand(edi, HeapNumber::kValueOffset)); |
| 3342 __ fsubp(1); |
| 3343 __ fstp_d(FieldOperand(edi, HeapNumber::kValueOffset)); |
| 3344 } |
| 3345 __ mov(eax, edi); |
| 3346 context()->Plug(eax); |
| 3347 } |
| 3348 |
| 3349 |
3299 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { | 3350 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { |
3300 // Load the arguments on the stack and call the stub. | 3351 // Load the arguments on the stack and call the stub. |
3301 SubStringStub stub; | 3352 SubStringStub stub; |
3302 ZoneList<Expression*>* args = expr->arguments(); | 3353 ZoneList<Expression*>* args = expr->arguments(); |
3303 ASSERT(args->length() == 3); | 3354 ASSERT(args->length() == 3); |
3304 VisitForStackValue(args->at(0)); | 3355 VisitForStackValue(args->at(0)); |
3305 VisitForStackValue(args->at(1)); | 3356 VisitForStackValue(args->at(1)); |
3306 VisitForStackValue(args->at(2)); | 3357 VisitForStackValue(args->at(2)); |
3307 __ CallStub(&stub); | 3358 __ CallStub(&stub); |
3308 context()->Plug(eax); | 3359 context()->Plug(eax); |
(...skipping 1594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4903 | 4954 |
4904 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4955 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
4905 Assembler::target_address_at(call_target_address)); | 4956 Assembler::target_address_at(call_target_address)); |
4906 return OSR_AFTER_STACK_CHECK; | 4957 return OSR_AFTER_STACK_CHECK; |
4907 } | 4958 } |
4908 | 4959 |
4909 | 4960 |
4910 } } // namespace v8::internal | 4961 } } // namespace v8::internal |
4911 | 4962 |
4912 #endif // V8_TARGET_ARCH_IA32 | 4963 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |