Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: src/x64/stub-cache-x64.cc

Issue 12426008: Load/Store stub compilation refactoring. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2359 matching lines...) Expand 10 before | Expand all | Expand 10 after
2370 __ IncrementCounter(counters->call_global_inline_miss(), 1); 2370 __ IncrementCounter(counters->call_global_inline_miss(), 1);
2371 GenerateMissBranch(); 2371 GenerateMissBranch();
2372 2372
2373 // Return the generated code. 2373 // Return the generated code.
2374 return GetCode(Code::NORMAL, name); 2374 return GetCode(Code::NORMAL, name);
2375 } 2375 }
2376 2376
2377 2377
2378 Handle<Code> StoreStubCompiler::CompileStoreCallback( 2378 Handle<Code> StoreStubCompiler::CompileStoreCallback(
2379 Handle<Name> name, 2379 Handle<Name> name,
2380 Handle<JSObject> receiver, 2380 Handle<JSObject> object,
2381 Handle<JSObject> holder, 2381 Handle<JSObject> holder,
2382 Handle<ExecutableAccessorInfo> callback) { 2382 Handle<ExecutableAccessorInfo> callback) {
2383 // ----------- S t a t e -------------
2384 // -- rax : value
2385 // -- rcx : name
2386 // -- rdx : receiver
2387 // -- rsp[0] : return address
2388 // -----------------------------------
2389 Label miss; 2383 Label miss;
2390 // Check that the maps haven't changed. 2384 // Check that the maps haven't changed.
2391 __ JumpIfSmi(rdx, &miss); 2385 __ JumpIfSmi(receiver(), &miss);
2392 CheckPrototypes(receiver, rdx, holder, rbx, r8, rdi, name, &miss); 2386 CheckPrototypes(object, receiver(), holder,
2387 scratch1(), scratch2(), scratch3(), name, &miss);
2393 2388
2394 // Stub never generated for non-global objects that require access checks. 2389 // Stub never generated for non-global objects that require access checks.
2395 ASSERT(holder->IsJSGlobalProxy() || !holder->IsAccessCheckNeeded()); 2390 ASSERT(holder->IsJSGlobalProxy() || !holder->IsAccessCheckNeeded());
2396 2391
2397 __ pop(rbx); // remove the return address 2392 __ pop(scratch1()); // remove the return address
2398 __ push(rdx); // receiver 2393 __ push(receiver());
2399 __ Push(callback); // callback info 2394 __ Push(callback); // callback info
2400 __ push(rcx); // name 2395 __ push(this->name());
2401 __ push(rax); // value 2396 __ push(value());
2402 __ push(rbx); // restore return address 2397 __ push(scratch1()); // restore return address
2403 2398
2404 // Do tail-call to the runtime system. 2399 // Do tail-call to the runtime system.
2405 ExternalReference store_callback_property = 2400 ExternalReference store_callback_property =
2406 ExternalReference(IC_Utility(IC::kStoreCallbackProperty), isolate()); 2401 ExternalReference(IC_Utility(IC::kStoreCallbackProperty), isolate());
2407 __ TailCallExternalReference(store_callback_property, 4, 1); 2402 __ TailCallExternalReference(store_callback_property, 4, 1);
2408 2403
2409 // Handle store cache miss. 2404 // Handle store cache miss.
2410 __ bind(&miss); 2405 __ bind(&miss);
2411 TailCallBuiltin(masm(), MissBuiltin(kind())); 2406 TailCallBuiltin(masm(), MissBuiltin(kind()));
2412 2407
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2454 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); 2449 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2455 } 2450 }
2456 __ ret(0); 2451 __ ret(0);
2457 } 2452 }
2458 2453
2459 2454
2460 #undef __ 2455 #undef __
2461 #define __ ACCESS_MASM(masm()) 2456 #define __ ACCESS_MASM(masm())
2462 2457
2463 2458
2464 Handle<Code> StoreStubCompiler::CompileStoreViaSetter(
2465 Handle<Name> name,
2466 Handle<JSObject> receiver,
2467 Handle<JSObject> holder,
2468 Handle<JSFunction> setter) {
2469 // ----------- S t a t e -------------
2470 // -- rax : value
2471 // -- rcx : name
2472 // -- rdx : receiver
2473 // -- rsp[0] : return address
2474 // -----------------------------------
2475 Label miss;
2476
2477 // Check that the maps haven't changed.
2478 __ JumpIfSmi(rdx, &miss);
2479 CheckPrototypes(receiver, rdx, holder, rbx, r8, rdi, name, &miss);
2480
2481 GenerateStoreViaSetter(masm(), setter);
2482
2483 __ bind(&miss);
2484 TailCallBuiltin(masm(), MissBuiltin(kind()));
2485
2486 // Return the generated code.
2487 return GetICCode(kind(), Code::CALLBACKS, name);
2488 }
2489
2490
2491 Handle<Code> StoreStubCompiler::CompileStoreInterceptor( 2459 Handle<Code> StoreStubCompiler::CompileStoreInterceptor(
2492 Handle<JSObject> receiver, 2460 Handle<JSObject> object,
2493 Handle<Name> name) { 2461 Handle<Name> name) {
2494 // ----------- S t a t e -------------
2495 // -- rax : value
2496 // -- rcx : name
2497 // -- rdx : receiver
2498 // -- rsp[0] : return address
2499 // -----------------------------------
2500 Label miss; 2462 Label miss;
2501 2463
2502 // Check that the map of the object hasn't changed. 2464 // Check that the map of the object hasn't changed.
2503 __ CheckMap(rdx, Handle<Map>(receiver->map()), &miss, 2465 __ CheckMap(receiver(), Handle<Map>(object->map()), &miss,
2504 DO_SMI_CHECK, ALLOW_ELEMENT_TRANSITION_MAPS); 2466 DO_SMI_CHECK, ALLOW_ELEMENT_TRANSITION_MAPS);
2505 2467
2506 // Perform global security token check if needed. 2468 // Perform global security token check if needed.
2507 if (receiver->IsJSGlobalProxy()) { 2469 if (object->IsJSGlobalProxy()) {
2508 __ CheckAccessGlobalProxy(rdx, rbx, &miss); 2470 __ CheckAccessGlobalProxy(receiver(), scratch1(), &miss);
2509 } 2471 }
2510 2472
2511 // Stub never generated for non-global objects that require access 2473 // Stub never generated for non-global objects that require access
2512 // checks. 2474 // checks.
2513 ASSERT(receiver->IsJSGlobalProxy() || !receiver->IsAccessCheckNeeded()); 2475 ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded());
2514 2476
2515 __ pop(rbx); // remove the return address 2477 __ pop(scratch1()); // remove the return address
2516 __ push(rdx); // receiver 2478 __ push(receiver());
2517 __ push(rcx); // name 2479 __ push(this->name());
2518 __ push(rax); // value 2480 __ push(value());
2519 __ Push(Smi::FromInt(strict_mode())); 2481 __ Push(Smi::FromInt(strict_mode()));
2520 __ push(rbx); // restore return address 2482 __ push(scratch1()); // restore return address
2521 2483
2522 // Do tail-call to the runtime system. 2484 // Do tail-call to the runtime system.
2523 ExternalReference store_ic_property = 2485 ExternalReference store_ic_property =
2524 ExternalReference(IC_Utility(IC::kStoreInterceptorProperty), isolate()); 2486 ExternalReference(IC_Utility(IC::kStoreInterceptorProperty), isolate());
2525 __ TailCallExternalReference(store_ic_property, 4, 1); 2487 __ TailCallExternalReference(store_ic_property, 4, 1);
2526 2488
2527 // Handle store cache miss. 2489 // Handle store cache miss.
2528 __ bind(&miss); 2490 __ bind(&miss);
2529 TailCallBuiltin(masm(), MissBuiltin(kind())); 2491 TailCallBuiltin(masm(), MissBuiltin(kind()));
2530 2492
2531 // Return the generated code. 2493 // Return the generated code.
2532 return GetICCode(kind(), Code::INTERCEPTOR, name); 2494 return GetICCode(kind(), Code::INTERCEPTOR, name);
2533 } 2495 }
2534 2496
2535 2497
2536 Handle<Code> StoreStubCompiler::CompileStoreGlobal( 2498 Handle<Code> StoreStubCompiler::CompileStoreGlobal(
2537 Handle<GlobalObject> object, 2499 Handle<GlobalObject> object,
2538 Handle<JSGlobalPropertyCell> cell, 2500 Handle<JSGlobalPropertyCell> cell,
2539 Handle<Name> name) { 2501 Handle<Name> name) {
2540 // ----------- S t a t e -------------
2541 // -- rax : value
2542 // -- rcx : name
2543 // -- rdx : receiver
2544 // -- rsp[0] : return address
2545 // -----------------------------------
2546 Label miss; 2502 Label miss;
2547 2503
2548 // Check that the map of the global has not changed. 2504 // Check that the map of the global has not changed.
2549 __ Cmp(FieldOperand(rdx, HeapObject::kMapOffset), 2505 __ Cmp(FieldOperand(receiver(), HeapObject::kMapOffset),
2550 Handle<Map>(object->map())); 2506 Handle<Map>(object->map()));
2551 __ j(not_equal, &miss); 2507 __ j(not_equal, &miss);
2552 2508
2553 // Compute the cell operand to use. 2509 // Compute the cell operand to use.
2554 __ Move(rbx, cell); 2510 __ Move(scratch1(), cell);
2555 Operand cell_operand = FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset); 2511 Operand cell_operand =
2512 FieldOperand(scratch1(), JSGlobalPropertyCell::kValueOffset);
2556 2513
2557 // Check that the value in the cell is not the hole. If it is, this 2514 // Check that the value in the cell is not the hole. If it is, this
2558 // cell could have been deleted and reintroducing the global needs 2515 // cell could have been deleted and reintroducing the global needs
2559 // to update the property details in the property dictionary of the 2516 // to update the property details in the property dictionary of the
2560 // global object. We bail out to the runtime system to do that. 2517 // global object. We bail out to the runtime system to do that.
2561 __ CompareRoot(cell_operand, Heap::kTheHoleValueRootIndex); 2518 __ CompareRoot(cell_operand, Heap::kTheHoleValueRootIndex);
2562 __ j(equal, &miss); 2519 __ j(equal, &miss);
2563 2520
2564 // Store the value in the cell. 2521 // Store the value in the cell.
2565 __ movq(cell_operand, rax); 2522 __ movq(cell_operand, value());
2566 // Cells are always rescanned, so no write barrier here. 2523 // Cells are always rescanned, so no write barrier here.
2567 2524
2568 // Return the value (register rax). 2525 // Return the value (register rax).
2569 Counters* counters = isolate()->counters(); 2526 Counters* counters = isolate()->counters();
2570 __ IncrementCounter(counters->named_store_global_inline(), 1); 2527 __ IncrementCounter(counters->named_store_global_inline(), 1);
2571 __ ret(0); 2528 __ ret(0);
2572 2529
2573 // Handle store cache miss. 2530 // Handle store cache miss.
2574 __ bind(&miss); 2531 __ bind(&miss);
2575 __ IncrementCounter(counters->named_store_global_inline_miss(), 1); 2532 __ IncrementCounter(counters->named_store_global_inline_miss(), 1);
2576 TailCallBuiltin(masm(), MissBuiltin(kind())); 2533 TailCallBuiltin(masm(), MissBuiltin(kind()));
2577 2534
2578 // Return the generated code. 2535 // Return the generated code.
2579 return GetICCode(kind(), Code::NORMAL, name); 2536 return GetICCode(kind(), Code::NORMAL, name);
2580 } 2537 }
2581 2538
2582 2539
2583 Handle<Code> KeyedStoreStubCompiler::CompileStoreElement(
2584 Handle<Map> receiver_map) {
2585 // ----------- S t a t e -------------
2586 // -- rax : value
2587 // -- rcx : key
2588 // -- rdx : receiver
2589 // -- rsp[0] : return address
2590 // -----------------------------------
2591
2592 ElementsKind elements_kind = receiver_map->elements_kind();
2593 bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
2594 Handle<Code> stub =
2595 KeyedStoreElementStub(is_js_array,
2596 elements_kind,
2597 store_mode_).GetCode(isolate());
2598
2599 __ DispatchMap(rdx, receiver_map, stub, DO_SMI_CHECK);
2600
2601 TailCallBuiltin(masm(), MissBuiltin(kind()));
2602
2603 // Return the generated code.
2604 return GetICCode(kind(), Code::NORMAL, factory()->empty_string());
2605 }
2606
2607
2608 Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic( 2540 Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
2609 MapHandleList* receiver_maps, 2541 MapHandleList* receiver_maps,
2610 CodeHandleList* handler_stubs, 2542 CodeHandleList* handler_stubs,
2611 MapHandleList* transitioned_maps) { 2543 MapHandleList* transitioned_maps) {
2612 // ----------- S t a t e -------------
2613 // -- rax : value
2614 // -- rcx : key
2615 // -- rdx : receiver
2616 // -- rsp[0] : return address
2617 // -----------------------------------
2618 Label miss; 2544 Label miss;
2619 __ JumpIfSmi(rdx, &miss, Label::kNear); 2545 __ JumpIfSmi(receiver(), &miss, Label::kNear);
2620 2546
2621 __ movq(rdi, FieldOperand(rdx, HeapObject::kMapOffset)); 2547 __ movq(scratch1(), FieldOperand(receiver(), HeapObject::kMapOffset));
2622 int receiver_count = receiver_maps->length(); 2548 int receiver_count = receiver_maps->length();
2623 for (int i = 0; i < receiver_count; ++i) { 2549 for (int i = 0; i < receiver_count; ++i) {
2624 // Check map and tail call if there's a match 2550 // Check map and tail call if there's a match
2625 __ Cmp(rdi, receiver_maps->at(i)); 2551 __ Cmp(scratch1(), receiver_maps->at(i));
2626 if (transitioned_maps->at(i).is_null()) { 2552 if (transitioned_maps->at(i).is_null()) {
2627 __ j(equal, handler_stubs->at(i), RelocInfo::CODE_TARGET); 2553 __ j(equal, handler_stubs->at(i), RelocInfo::CODE_TARGET);
2628 } else { 2554 } else {
2629 Label next_map; 2555 Label next_map;
2630 __ j(not_equal, &next_map, Label::kNear); 2556 __ j(not_equal, &next_map, Label::kNear);
2631 __ movq(rbx, transitioned_maps->at(i), RelocInfo::EMBEDDED_OBJECT); 2557 __ movq(transition_map(),
2558 transitioned_maps->at(i),
2559 RelocInfo::EMBEDDED_OBJECT);
2632 __ jmp(handler_stubs->at(i), RelocInfo::CODE_TARGET); 2560 __ jmp(handler_stubs->at(i), RelocInfo::CODE_TARGET);
2633 __ bind(&next_map); 2561 __ bind(&next_map);
2634 } 2562 }
2635 } 2563 }
2636 2564
2637 __ bind(&miss); 2565 __ bind(&miss);
2638 2566
2639 TailCallBuiltin(masm(), MissBuiltin(kind())); 2567 TailCallBuiltin(masm(), MissBuiltin(kind()));
2640 2568
2641 // Return the generated code. 2569 // Return the generated code.
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2779 Counters* counters = isolate()->counters(); 2707 Counters* counters = isolate()->counters();
2780 __ IncrementCounter(counters->named_load_global_stub(), 1); 2708 __ IncrementCounter(counters->named_load_global_stub(), 1);
2781 __ movq(rax, rbx); 2709 __ movq(rax, rbx);
2782 __ ret(0); 2710 __ ret(0);
2783 2711
2784 // Return the generated code. 2712 // Return the generated code.
2785 return GetICCode(kind(), Code::NORMAL, name); 2713 return GetICCode(kind(), Code::NORMAL, name);
2786 } 2714 }
2787 2715
2788 2716
2789 Handle<Code> KeyedLoadStubCompiler::CompileLoadElement(
2790 Handle<Map> receiver_map) {
2791 // ----------- S t a t e -------------
2792 // -- rax : key
2793 // -- rdx : receiver
2794 // -- rsp[0] : return address
2795 // -----------------------------------
2796 ElementsKind elements_kind = receiver_map->elements_kind();
2797 if (receiver_map->has_fast_elements() ||
2798 receiver_map->has_external_array_elements()) {
2799 Handle<Code> stub = KeyedLoadFastElementStub(
2800 receiver_map->instance_type() == JS_ARRAY_TYPE,
2801 elements_kind).GetCode(isolate());
2802 __ DispatchMap(rdx, receiver_map, stub, DO_SMI_CHECK);
2803 } else {
2804 Handle<Code> stub =
2805 KeyedLoadDictionaryElementStub().GetCode(isolate());
2806 __ DispatchMap(rdx, receiver_map, stub, DO_SMI_CHECK);
2807 }
2808
2809 TailCallBuiltin(masm(), Builtins::kKeyedLoadIC_Miss);
2810
2811 // Return the generated code.
2812 return GetICCode(kind(), Code::NORMAL, factory()->empty_string());
2813 }
2814
2815
2816 Handle<Code> BaseLoadStubCompiler::CompilePolymorphicIC( 2717 Handle<Code> BaseLoadStubCompiler::CompilePolymorphicIC(
2817 MapHandleList* receiver_maps, 2718 MapHandleList* receiver_maps,
2818 CodeHandleList* handlers, 2719 CodeHandleList* handlers,
2819 Handle<Name> name, 2720 Handle<Name> name,
2820 Code::StubType type, 2721 Code::StubType type,
2821 IcCheckType check) { 2722 IcCheckType check) {
2822 Label miss; 2723 Label miss;
2823 2724
2824 if (check == PROPERTY) { 2725 if (check == PROPERTY) {
2825 GenerateNameCheck(name, this->name(), &miss); 2726 GenerateNameCheck(name, this->name(), &miss);
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
3500 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); 3401 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
3501 } 3402 }
3502 } 3403 }
3503 3404
3504 3405
3505 #undef __ 3406 #undef __
3506 3407
3507 } } // namespace v8::internal 3408 } } // namespace v8::internal
3508 3409
3509 #endif // V8_TARGET_ARCH_X64 3410 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698