| 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 3254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3265 VisitForStackValue(args->at(1)); | 3265 VisitForStackValue(args->at(1)); |
| 3266 VisitForStackValue(args->at(2)); | 3266 VisitForStackValue(args->at(2)); |
| 3267 __ CallRuntime(Runtime::kLog, 2); | 3267 __ CallRuntime(Runtime::kLog, 2); |
| 3268 } | 3268 } |
| 3269 // Finally, we're expected to leave a value on the top of the stack. | 3269 // Finally, we're expected to leave a value on the top of the stack. |
| 3270 __ mov(eax, isolate()->factory()->undefined_value()); | 3270 __ mov(eax, isolate()->factory()->undefined_value()); |
| 3271 context()->Plug(eax); | 3271 context()->Plug(eax); |
| 3272 } | 3272 } |
| 3273 | 3273 |
| 3274 | 3274 |
| 3275 void FullCodeGenerator::EmitRandomHeapNumber(CallRuntime* expr) { | |
| 3276 ASSERT(expr->arguments()->length() == 0); | |
| 3277 | |
| 3278 Label slow_allocate_heapnumber; | |
| 3279 Label heapnumber_allocated; | |
| 3280 | |
| 3281 __ AllocateHeapNumber(edi, ebx, ecx, &slow_allocate_heapnumber); | |
| 3282 __ jmp(&heapnumber_allocated); | |
| 3283 | |
| 3284 __ bind(&slow_allocate_heapnumber); | |
| 3285 // Allocate a heap number. | |
| 3286 __ CallRuntime(Runtime::kNumberAlloc, 0); | |
| 3287 __ mov(edi, eax); | |
| 3288 | |
| 3289 __ bind(&heapnumber_allocated); | |
| 3290 | |
| 3291 __ PrepareCallCFunction(1, ebx); | |
| 3292 __ mov(eax, ContextOperand(context_register(), Context::GLOBAL_OBJECT_INDEX)); | |
| 3293 __ mov(eax, FieldOperand(eax, GlobalObject::kNativeContextOffset)); | |
| 3294 __ mov(Operand(esp, 0), eax); | |
| 3295 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1); | |
| 3296 | |
| 3297 // Convert 32 random bits in eax to 0.(32 random bits) in a double | |
| 3298 // by computing: | |
| 3299 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). | |
| 3300 // This is implemented on both SSE2 and FPU. | |
| 3301 if (CpuFeatures::IsSupported(SSE2)) { | |
| 3302 CpuFeatureScope fscope(masm(), SSE2); | |
| 3303 __ mov(ebx, Immediate(0x49800000)); // 1.0 x 2^20 as single. | |
| 3304 __ movd(xmm1, ebx); | |
| 3305 __ movd(xmm0, eax); | |
| 3306 __ cvtss2sd(xmm1, xmm1); | |
| 3307 __ xorps(xmm0, xmm1); | |
| 3308 __ subsd(xmm0, xmm1); | |
| 3309 __ movsd(FieldOperand(edi, HeapNumber::kValueOffset), xmm0); | |
| 3310 } else { | |
| 3311 // 0x4130000000000000 is 1.0 x 2^20 as a double. | |
| 3312 __ mov(FieldOperand(edi, HeapNumber::kExponentOffset), | |
| 3313 Immediate(0x41300000)); | |
| 3314 __ mov(FieldOperand(edi, HeapNumber::kMantissaOffset), eax); | |
| 3315 __ fld_d(FieldOperand(edi, HeapNumber::kValueOffset)); | |
| 3316 __ mov(FieldOperand(edi, HeapNumber::kMantissaOffset), Immediate(0)); | |
| 3317 __ fld_d(FieldOperand(edi, HeapNumber::kValueOffset)); | |
| 3318 __ fsubp(1); | |
| 3319 __ fstp_d(FieldOperand(edi, HeapNumber::kValueOffset)); | |
| 3320 } | |
| 3321 __ mov(eax, edi); | |
| 3322 context()->Plug(eax); | |
| 3323 } | |
| 3324 | |
| 3325 | |
| 3326 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { | 3275 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { |
| 3327 // Load the arguments on the stack and call the stub. | 3276 // Load the arguments on the stack and call the stub. |
| 3328 SubStringStub stub; | 3277 SubStringStub stub; |
| 3329 ZoneList<Expression*>* args = expr->arguments(); | 3278 ZoneList<Expression*>* args = expr->arguments(); |
| 3330 ASSERT(args->length() == 3); | 3279 ASSERT(args->length() == 3); |
| 3331 VisitForStackValue(args->at(0)); | 3280 VisitForStackValue(args->at(0)); |
| 3332 VisitForStackValue(args->at(1)); | 3281 VisitForStackValue(args->at(1)); |
| 3333 VisitForStackValue(args->at(2)); | 3282 VisitForStackValue(args->at(2)); |
| 3334 __ CallStub(&stub); | 3283 __ CallStub(&stub); |
| 3335 context()->Plug(eax); | 3284 context()->Plug(eax); |
| (...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4969 | 4918 |
| 4970 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4919 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 4971 Assembler::target_address_at(call_target_address)); | 4920 Assembler::target_address_at(call_target_address)); |
| 4972 return OSR_AFTER_STACK_CHECK; | 4921 return OSR_AFTER_STACK_CHECK; |
| 4973 } | 4922 } |
| 4974 | 4923 |
| 4975 | 4924 |
| 4976 } } // namespace v8::internal | 4925 } } // namespace v8::internal |
| 4977 | 4926 |
| 4978 #endif // V8_TARGET_ARCH_IA32 | 4927 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |