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

Side by Side Diff: src/ic.cc

Issue 71973003: Limit target() / raw_target() visibility to ICs. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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/ic.h ('k') | src/stub-cache.cc » ('j') | 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 2529 matching lines...) Expand 10 before | Expand all | Expand 10 after
2540 case UNIQUE_NAME: 2540 case UNIQUE_NAME:
2541 case OBJECT: 2541 case OBJECT:
2542 case GENERIC: 2542 case GENERIC:
2543 return GENERIC; 2543 return GENERIC;
2544 } 2544 }
2545 UNREACHABLE(); 2545 UNREACHABLE();
2546 return GENERIC; // Make the compiler happy. 2546 return GENERIC; // Make the compiler happy.
2547 } 2547 }
2548 2548
2549 2549
2550 void CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) { 2550 Code* CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) {
2551 HandleScope scope(isolate()); 2551 HandleScope scope(isolate());
2552 State previous_left, previous_right, previous_state; 2552 State previous_left, previous_right, previous_state;
2553 ICCompareStub::DecodeMinorKey(target()->stub_info(), &previous_left, 2553 ICCompareStub::DecodeMinorKey(target()->stub_info(), &previous_left,
2554 &previous_right, &previous_state, NULL); 2554 &previous_right, &previous_state, NULL);
2555 State new_left = NewInputState(previous_left, x); 2555 State new_left = NewInputState(previous_left, x);
2556 State new_right = NewInputState(previous_right, y); 2556 State new_right = NewInputState(previous_right, y);
2557 State state = TargetState(previous_state, previous_left, previous_right, 2557 State state = TargetState(previous_state, previous_left, previous_right,
2558 HasInlinedSmiCode(address()), x, y); 2558 HasInlinedSmiCode(address()), x, y);
2559 ICCompareStub stub(op_, new_left, new_right, state); 2559 ICCompareStub stub(op_, new_left, new_right, state);
2560 if (state == KNOWN_OBJECT) { 2560 if (state == KNOWN_OBJECT) {
2561 stub.set_known_map( 2561 stub.set_known_map(
2562 Handle<Map>(Handle<JSObject>::cast(x)->map(), isolate())); 2562 Handle<Map>(Handle<JSObject>::cast(x)->map(), isolate()));
2563 } 2563 }
2564 set_target(*stub.GetCode(isolate())); 2564 Handle<Code> new_target = stub.GetCode(isolate());
2565 set_target(*new_target);
2565 2566
2566 #ifdef DEBUG 2567 #ifdef DEBUG
2567 if (FLAG_trace_ic) { 2568 if (FLAG_trace_ic) {
2568 PrintF("[CompareIC in "); 2569 PrintF("[CompareIC in ");
2569 JavaScriptFrame::PrintTop(isolate(), stdout, false, true); 2570 JavaScriptFrame::PrintTop(isolate(), stdout, false, true);
2570 PrintF(" ((%s+%s=%s)->(%s+%s=%s))#%s @ %p]\n", 2571 PrintF(" ((%s+%s=%s)->(%s+%s=%s))#%s @ %p]\n",
2571 GetStateName(previous_left), 2572 GetStateName(previous_left),
2572 GetStateName(previous_right), 2573 GetStateName(previous_right),
2573 GetStateName(previous_state), 2574 GetStateName(previous_state),
2574 GetStateName(new_left), 2575 GetStateName(new_left),
2575 GetStateName(new_right), 2576 GetStateName(new_right),
2576 GetStateName(state), 2577 GetStateName(state),
2577 Token::Name(op_), 2578 Token::Name(op_),
2578 static_cast<void*>(*stub.GetCode(isolate()))); 2579 static_cast<void*>(*stub.GetCode(isolate())));
2579 } 2580 }
2580 #endif 2581 #endif
2581 2582
2582 // Activate inlined smi code. 2583 // Activate inlined smi code.
2583 if (previous_state == UNINITIALIZED) { 2584 if (previous_state == UNINITIALIZED) {
2584 PatchInlinedSmiCode(address(), ENABLE_INLINED_SMI_CHECK); 2585 PatchInlinedSmiCode(address(), ENABLE_INLINED_SMI_CHECK);
2585 } 2586 }
2587
2588 return *new_target;
2586 } 2589 }
2587 2590
2588 2591
2589 // Used from ICCompareStub::GenerateMiss in code-stubs-<arch>.cc. 2592 // Used from ICCompareStub::GenerateMiss in code-stubs-<arch>.cc.
2590 RUNTIME_FUNCTION(Code*, CompareIC_Miss) { 2593 RUNTIME_FUNCTION(Code*, CompareIC_Miss) {
2591 HandleScope scope(isolate); 2594 HandleScope scope(isolate);
2592 ASSERT(args.length() == 3); 2595 ASSERT(args.length() == 3);
2593 CompareIC ic(isolate, static_cast<Token::Value>(args.smi_at(2))); 2596 CompareIC ic(isolate, static_cast<Token::Value>(args.smi_at(2)));
2594 ic.UpdateCaches(args.at<Object>(0), args.at<Object>(1)); 2597 return ic.UpdateCaches(args.at<Object>(0), args.at<Object>(1));
2595 return ic.raw_target();
2596 } 2598 }
2597 2599
2598 2600
2599 void CompareNilIC::Clear(Address address, Code* target) { 2601 void CompareNilIC::Clear(Address address, Code* target) {
2600 if (IsCleared(target)) return; 2602 if (IsCleared(target)) return;
2601 Code::ExtraICState state = target->extended_extra_ic_state(); 2603 Code::ExtraICState state = target->extended_extra_ic_state();
2602 2604
2603 CompareNilICStub stub(state, HydrogenCodeStub::UNINITIALIZED); 2605 CompareNilICStub stub(state, HydrogenCodeStub::UNINITIALIZED);
2604 stub.ClearState(); 2606 stub.ClearState();
2605 2607
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2696 case Token::SHR: 2698 case Token::SHR:
2697 return Builtins::SHR; 2699 return Builtins::SHR;
2698 break; 2700 break;
2699 case Token::SHL: 2701 case Token::SHL:
2700 return Builtins::SHL; 2702 return Builtins::SHL;
2701 break; 2703 break;
2702 } 2704 }
2703 } 2705 }
2704 2706
2705 2707
2706 MaybeObject* ToBooleanIC::ToBoolean(Handle<Object> object, 2708 MaybeObject* ToBooleanIC::ToBoolean(Handle<Object> object) {
2707 Code::ExtraICState extra_ic_state) { 2709 ToBooleanStub stub(target()->extended_extra_ic_state());
2708 ToBooleanStub stub(extra_ic_state);
2709 bool to_boolean_value = stub.UpdateStatus(object); 2710 bool to_boolean_value = stub.UpdateStatus(object);
2710 Handle<Code> code = stub.GetCode(isolate()); 2711 Handle<Code> code = stub.GetCode(isolate());
2711 set_target(*code); 2712 set_target(*code);
2712 return Smi::FromInt(to_boolean_value ? 1 : 0); 2713 return Smi::FromInt(to_boolean_value ? 1 : 0);
2713 } 2714 }
2714 2715
2715 2716
2716 RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss) { 2717 RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss) {
2717 ASSERT(args.length() == 1); 2718 ASSERT(args.length() == 1);
2718 HandleScope scope(isolate); 2719 HandleScope scope(isolate);
2719 Handle<Object> object = args.at<Object>(0); 2720 Handle<Object> object = args.at<Object>(0);
2720 ToBooleanIC ic(isolate); 2721 ToBooleanIC ic(isolate);
2721 Code::ExtraICState extra_ic_state = ic.target()->extended_extra_ic_state(); 2722 return ic.ToBoolean(object);
2722 return ic.ToBoolean(object, extra_ic_state);
2723 } 2723 }
2724 2724
2725 2725
2726 static const Address IC_utilities[] = { 2726 static const Address IC_utilities[] = {
2727 #define ADDR(name) FUNCTION_ADDR(name), 2727 #define ADDR(name) FUNCTION_ADDR(name),
2728 IC_UTIL_LIST(ADDR) 2728 IC_UTIL_LIST(ADDR)
2729 NULL 2729 NULL
2730 #undef ADDR 2730 #undef ADDR
2731 }; 2731 };
2732 2732
2733 2733
2734 Address IC::AddressFromUtilityId(IC::UtilityId id) { 2734 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2735 return IC_utilities[id]; 2735 return IC_utilities[id];
2736 } 2736 }
2737 2737
2738 2738
2739 } } // namespace v8::internal 2739 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic.h ('k') | src/stub-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698