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 22 matching lines...) Expand all Loading... |
33 #include "code-stubs.h" | 33 #include "code-stubs.h" |
34 #include "isolate.h" | 34 #include "isolate.h" |
35 #include "jsregexp.h" | 35 #include "jsregexp.h" |
36 #include "regexp-macro-assembler.h" | 36 #include "regexp-macro-assembler.h" |
37 #include "stub-cache.h" | 37 #include "stub-cache.h" |
38 #include "codegen.h" | 38 #include "codegen.h" |
39 | 39 |
40 namespace v8 { | 40 namespace v8 { |
41 namespace internal { | 41 namespace internal { |
42 | 42 |
| 43 |
| 44 CodeStubInterfaceDescriptor* |
| 45 KeyedLoadFastElementStub::GetInterfaceDescriptor(Isolate* isolate) { |
| 46 static CodeStubInterfaceDescriptor* result = NULL; |
| 47 if (result == NULL) { |
| 48 Handle<Code> miss = isolate->builtins()->KeyedLoadIC_Miss(); |
| 49 static Register registers[] = { edx, ecx }; |
| 50 static CodeStubInterfaceDescriptor info = { |
| 51 2, |
| 52 registers, |
| 53 miss |
| 54 }; |
| 55 result = &info; |
| 56 } |
| 57 return result; |
| 58 } |
| 59 |
| 60 |
43 #define __ ACCESS_MASM(masm) | 61 #define __ ACCESS_MASM(masm) |
44 | 62 |
45 void ToNumberStub::Generate(MacroAssembler* masm) { | 63 void ToNumberStub::Generate(MacroAssembler* masm) { |
46 // The ToNumber stub takes one argument in eax. | 64 // The ToNumber stub takes one argument in eax. |
47 Label check_heap_number, call_builtin; | 65 Label check_heap_number, call_builtin; |
48 __ JumpIfNotSmi(eax, &check_heap_number, Label::kNear); | 66 __ JumpIfNotSmi(eax, &check_heap_number, Label::kNear); |
49 __ ret(0); | 67 __ ret(0); |
50 | 68 |
51 __ bind(&check_heap_number); | 69 __ bind(&check_heap_number); |
52 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | 70 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
(...skipping 2366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2419 __ cmp(ebx, Immediate(factory->heap_number_map())); | 2437 __ cmp(ebx, Immediate(factory->heap_number_map())); |
2420 __ j(not_equal, &runtime_call); | 2438 __ j(not_equal, &runtime_call); |
2421 // Input is a HeapNumber. Push it on the FPU stack and load its | 2439 // Input is a HeapNumber. Push it on the FPU stack and load its |
2422 // low and high words into ebx, edx. | 2440 // low and high words into ebx, edx. |
2423 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); | 2441 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); |
2424 __ mov(edx, FieldOperand(eax, HeapNumber::kExponentOffset)); | 2442 __ mov(edx, FieldOperand(eax, HeapNumber::kExponentOffset)); |
2425 __ mov(ebx, FieldOperand(eax, HeapNumber::kMantissaOffset)); | 2443 __ mov(ebx, FieldOperand(eax, HeapNumber::kMantissaOffset)); |
2426 | 2444 |
2427 __ bind(&loaded); | 2445 __ bind(&loaded); |
2428 } else { // UNTAGGED. | 2446 } else { // UNTAGGED. |
| 2447 CpuFeatures::Scope scope(SSE2); |
2429 if (CpuFeatures::IsSupported(SSE4_1)) { | 2448 if (CpuFeatures::IsSupported(SSE4_1)) { |
2430 CpuFeatures::Scope sse4_scope(SSE4_1); | 2449 CpuFeatures::Scope sse4_scope(SSE4_1); |
2431 __ pextrd(edx, xmm1, 0x1); // copy xmm1[63..32] to edx. | 2450 __ pextrd(edx, xmm1, 0x1); // copy xmm1[63..32] to edx. |
2432 } else { | 2451 } else { |
2433 __ pshufd(xmm0, xmm1, 0x1); | 2452 __ pshufd(xmm0, xmm1, 0x1); |
2434 __ movd(edx, xmm0); | 2453 __ movd(edx, xmm0); |
2435 } | 2454 } |
2436 __ movd(ebx, xmm1); | 2455 __ movd(ebx, xmm1); |
2437 } | 2456 } |
2438 | 2457 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2491 __ cmp(edx, Operand(ecx, kIntSize)); | 2510 __ cmp(edx, Operand(ecx, kIntSize)); |
2492 __ j(not_equal, &cache_miss, Label::kNear); | 2511 __ j(not_equal, &cache_miss, Label::kNear); |
2493 // Cache hit! | 2512 // Cache hit! |
2494 Counters* counters = masm->isolate()->counters(); | 2513 Counters* counters = masm->isolate()->counters(); |
2495 __ IncrementCounter(counters->transcendental_cache_hit(), 1); | 2514 __ IncrementCounter(counters->transcendental_cache_hit(), 1); |
2496 __ mov(eax, Operand(ecx, 2 * kIntSize)); | 2515 __ mov(eax, Operand(ecx, 2 * kIntSize)); |
2497 if (tagged) { | 2516 if (tagged) { |
2498 __ fstp(0); | 2517 __ fstp(0); |
2499 __ ret(kPointerSize); | 2518 __ ret(kPointerSize); |
2500 } else { // UNTAGGED. | 2519 } else { // UNTAGGED. |
| 2520 CpuFeatures::Scope scope(SSE2); |
2501 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset)); | 2521 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset)); |
2502 __ Ret(); | 2522 __ Ret(); |
2503 } | 2523 } |
2504 | 2524 |
2505 __ bind(&cache_miss); | 2525 __ bind(&cache_miss); |
2506 __ IncrementCounter(counters->transcendental_cache_miss(), 1); | 2526 __ IncrementCounter(counters->transcendental_cache_miss(), 1); |
2507 // Update cache with new value. | 2527 // Update cache with new value. |
2508 // We are short on registers, so use no_reg as scratch. | 2528 // We are short on registers, so use no_reg as scratch. |
2509 // This gives slightly larger code. | 2529 // This gives slightly larger code. |
2510 if (tagged) { | 2530 if (tagged) { |
2511 __ AllocateHeapNumber(eax, edi, no_reg, &runtime_call_clear_stack); | 2531 __ AllocateHeapNumber(eax, edi, no_reg, &runtime_call_clear_stack); |
2512 } else { // UNTAGGED. | 2532 } else { // UNTAGGED. |
| 2533 CpuFeatures::Scope scope(SSE2); |
2513 __ AllocateHeapNumber(eax, edi, no_reg, &skip_cache); | 2534 __ AllocateHeapNumber(eax, edi, no_reg, &skip_cache); |
2514 __ sub(esp, Immediate(kDoubleSize)); | 2535 __ sub(esp, Immediate(kDoubleSize)); |
2515 __ movdbl(Operand(esp, 0), xmm1); | 2536 __ movdbl(Operand(esp, 0), xmm1); |
2516 __ fld_d(Operand(esp, 0)); | 2537 __ fld_d(Operand(esp, 0)); |
2517 __ add(esp, Immediate(kDoubleSize)); | 2538 __ add(esp, Immediate(kDoubleSize)); |
2518 } | 2539 } |
2519 GenerateOperation(masm, type_); | 2540 GenerateOperation(masm, type_); |
2520 __ mov(Operand(ecx, 0), ebx); | 2541 __ mov(Operand(ecx, 0), ebx); |
2521 __ mov(Operand(ecx, kIntSize), edx); | 2542 __ mov(Operand(ecx, kIntSize), edx); |
2522 __ mov(Operand(ecx, 2 * kIntSize), eax); | 2543 __ mov(Operand(ecx, 2 * kIntSize), eax); |
2523 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); | 2544 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); |
2524 if (tagged) { | 2545 if (tagged) { |
2525 __ ret(kPointerSize); | 2546 __ ret(kPointerSize); |
2526 } else { // UNTAGGED. | 2547 } else { // UNTAGGED. |
| 2548 CpuFeatures::Scope scope(SSE2); |
2527 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset)); | 2549 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset)); |
2528 __ Ret(); | 2550 __ Ret(); |
2529 | 2551 |
2530 // Skip cache and return answer directly, only in untagged case. | 2552 // Skip cache and return answer directly, only in untagged case. |
2531 __ bind(&skip_cache); | 2553 __ bind(&skip_cache); |
2532 __ sub(esp, Immediate(kDoubleSize)); | 2554 __ sub(esp, Immediate(kDoubleSize)); |
2533 __ movdbl(Operand(esp, 0), xmm1); | 2555 __ movdbl(Operand(esp, 0), xmm1); |
2534 __ fld_d(Operand(esp, 0)); | 2556 __ fld_d(Operand(esp, 0)); |
2535 GenerateOperation(masm, type_); | 2557 GenerateOperation(masm, type_); |
2536 __ fstp_d(Operand(esp, 0)); | 2558 __ fstp_d(Operand(esp, 0)); |
(...skipping 12 matching lines...) Expand all Loading... |
2549 | 2571 |
2550 // Call runtime, doing whatever allocation and cleanup is necessary. | 2572 // Call runtime, doing whatever allocation and cleanup is necessary. |
2551 if (tagged) { | 2573 if (tagged) { |
2552 __ bind(&runtime_call_clear_stack); | 2574 __ bind(&runtime_call_clear_stack); |
2553 __ fstp(0); | 2575 __ fstp(0); |
2554 __ bind(&runtime_call); | 2576 __ bind(&runtime_call); |
2555 ExternalReference runtime = | 2577 ExternalReference runtime = |
2556 ExternalReference(RuntimeFunction(), masm->isolate()); | 2578 ExternalReference(RuntimeFunction(), masm->isolate()); |
2557 __ TailCallExternalReference(runtime, 1, 1); | 2579 __ TailCallExternalReference(runtime, 1, 1); |
2558 } else { // UNTAGGED. | 2580 } else { // UNTAGGED. |
| 2581 CpuFeatures::Scope scope(SSE2); |
2559 __ bind(&runtime_call_clear_stack); | 2582 __ bind(&runtime_call_clear_stack); |
2560 __ bind(&runtime_call); | 2583 __ bind(&runtime_call); |
2561 __ AllocateHeapNumber(eax, edi, no_reg, &skip_cache); | 2584 __ AllocateHeapNumber(eax, edi, no_reg, &skip_cache); |
2562 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm1); | 2585 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm1); |
2563 { | 2586 { |
2564 FrameScope scope(masm, StackFrame::INTERNAL); | 2587 FrameScope scope(masm, StackFrame::INTERNAL); |
2565 __ push(eax); | 2588 __ push(eax); |
2566 __ CallRuntime(RuntimeFunction(), 1); | 2589 __ CallRuntime(RuntimeFunction(), 1); |
2567 } | 2590 } |
2568 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset)); | 2591 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset)); |
(...skipping 2232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4801 | 4824 |
4802 void CodeStub::GenerateStubsAheadOfTime() { | 4825 void CodeStub::GenerateStubsAheadOfTime() { |
4803 CEntryStub::GenerateAheadOfTime(); | 4826 CEntryStub::GenerateAheadOfTime(); |
4804 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(); | 4827 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(); |
4805 // It is important that the store buffer overflow stubs are generated first. | 4828 // It is important that the store buffer overflow stubs are generated first. |
4806 RecordWriteStub::GenerateFixedRegStubsAheadOfTime(); | 4829 RecordWriteStub::GenerateFixedRegStubsAheadOfTime(); |
4807 } | 4830 } |
4808 | 4831 |
4809 | 4832 |
4810 void CodeStub::GenerateFPStubs() { | 4833 void CodeStub::GenerateFPStubs() { |
4811 CEntryStub save_doubles(1, kSaveFPRegs); | 4834 if (CpuFeatures::IsSupported(SSE2)) { |
4812 Handle<Code> code = save_doubles.GetCode(); | 4835 CEntryStub save_doubles(1, kSaveFPRegs); |
4813 code->set_is_pregenerated(true); | 4836 // Stubs might already be in the snapshot, detect that and don't regenerate, |
4814 code->GetIsolate()->set_fp_stubs_generated(true); | 4837 // which would lead to code stub initialization state being messed up. |
| 4838 Code* save_doubles_code; |
| 4839 if (!save_doubles.FindCodeInCache(&save_doubles_code, ISOLATE)) { |
| 4840 save_doubles_code = *(save_doubles.GetCode()); |
| 4841 } |
| 4842 save_doubles_code->set_is_pregenerated(true); |
| 4843 save_doubles_code->GetIsolate()->set_fp_stubs_generated(true); |
| 4844 } |
4815 } | 4845 } |
4816 | 4846 |
4817 | 4847 |
4818 void CEntryStub::GenerateAheadOfTime() { | 4848 void CEntryStub::GenerateAheadOfTime() { |
4819 CEntryStub stub(1, kDontSaveFPRegs); | 4849 CEntryStub stub(1, kDontSaveFPRegs); |
4820 Handle<Code> code = stub.GetCode(); | 4850 Handle<Code> code = stub.GetCode(); |
4821 code->set_is_pregenerated(true); | 4851 code->set_is_pregenerated(true); |
4822 } | 4852 } |
4823 | 4853 |
4824 | 4854 |
(...skipping 2624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7449 // Restore ecx. | 7479 // Restore ecx. |
7450 __ pop(ecx); | 7480 __ pop(ecx); |
7451 __ ret(0); | 7481 __ ret(0); |
7452 } | 7482 } |
7453 | 7483 |
7454 #undef __ | 7484 #undef __ |
7455 | 7485 |
7456 } } // namespace v8::internal | 7486 } } // namespace v8::internal |
7457 | 7487 |
7458 #endif // V8_TARGET_ARCH_IA32 | 7488 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |