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

Side by Side Diff: src/ic-inl.h

Issue 195983002: Reland "Pass a Code object to Assembler::(set_)target_address_at for use by ool constant pool." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix ia32 and x64 bug/ Created 6 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/ic.cc ('k') | src/objects.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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 Address result = Assembler::target_address_from_return_address(pc()); 43 Address result = Assembler::target_address_from_return_address(pc());
44 44
45 #ifdef ENABLE_DEBUGGER_SUPPORT 45 #ifdef ENABLE_DEBUGGER_SUPPORT
46 Debug* debug = isolate()->debug(); 46 Debug* debug = isolate()->debug();
47 // First check if any break points are active if not just return the address 47 // First check if any break points are active if not just return the address
48 // of the call. 48 // of the call.
49 if (!debug->has_break_points()) return result; 49 if (!debug->has_break_points()) return result;
50 50
51 // At least one break point is active perform additional test to ensure that 51 // At least one break point is active perform additional test to ensure that
52 // break point locations are updated correctly. 52 // break point locations are updated correctly.
53 if (debug->IsDebugBreak(Assembler::target_address_at(result))) { 53 if (debug->IsDebugBreak(Assembler::target_address_at(result,
54 raw_constant_pool()))) {
54 // If the call site is a call to debug break then return the address in 55 // If the call site is a call to debug break then return the address in
55 // the original code instead of the address in the running code. This will 56 // the original code instead of the address in the running code. This will
56 // cause the original code to be updated and keeps the breakpoint active in 57 // cause the original code to be updated and keeps the breakpoint active in
57 // the running code. 58 // the running code.
58 return OriginalCodeAddress(); 59 Code* code = GetCode();
60 Code* original_code = GetOriginalCode();
61 intptr_t delta =
62 original_code->instruction_start() - code->instruction_start();
63 // Return the address in the original code. This is the place where
64 // the call which has been overwritten by the DebugBreakXXX resides
65 // and the place where the inline cache system should look.
66 return result + delta;
59 } else { 67 } else {
60 // No break point here just return the address of the call. 68 // No break point here just return the address of the call.
61 return result; 69 return result;
62 } 70 }
63 #else 71 #else
64 return result; 72 return result;
65 #endif 73 #endif
66 } 74 }
67 75
68 76
69 Code* IC::GetTargetAtAddress(Address address) { 77 ConstantPoolArray* IC::constant_pool() const {
78 if (!FLAG_enable_ool_constant_pool) {
79 return NULL;
80 } else {
81 Handle<ConstantPoolArray> result = raw_constant_pool_;
82 #ifdef ENABLE_DEBUGGER_SUPPORT
83 Debug* debug = isolate()->debug();
84 // First check if any break points are active if not just return the
85 // original constant pool.
86 if (!debug->has_break_points()) return *result;
87
88 // At least one break point is active perform additional test to ensure that
89 // break point locations are updated correctly.
90 Address target = Assembler::target_address_from_return_address(pc());
91 if (debug->IsDebugBreak(
92 Assembler::target_address_at(target, raw_constant_pool()))) {
93 // If the call site is a call to debug break then we want to return the
94 // constant pool for the original code instead of the breakpointed code.
95 return GetOriginalCode()->constant_pool();
96 }
97 #endif
98 return *result;
99 }
100 }
101
102
103 ConstantPoolArray* IC::raw_constant_pool() const {
104 if (FLAG_enable_ool_constant_pool) {
105 return *raw_constant_pool_;
106 } else {
107 return NULL;
108 }
109 }
110
111
112 Code* IC::GetTargetAtAddress(Address address,
113 ConstantPoolArray* constant_pool) {
70 // Get the target address of the IC. 114 // Get the target address of the IC.
71 Address target = Assembler::target_address_at(address); 115 Address target = Assembler::target_address_at(address, constant_pool);
72 // Convert target address to the code object. Code::GetCodeFromTargetAddress 116 // Convert target address to the code object. Code::GetCodeFromTargetAddress
73 // is safe for use during GC where the map might be marked. 117 // is safe for use during GC where the map might be marked.
74 Code* result = Code::GetCodeFromTargetAddress(target); 118 Code* result = Code::GetCodeFromTargetAddress(target);
75 ASSERT(result->is_inline_cache_stub()); 119 ASSERT(result->is_inline_cache_stub());
76 return result; 120 return result;
77 } 121 }
78 122
79 123
80 void IC::SetTargetAtAddress(Address address, Code* target) { 124 void IC::SetTargetAtAddress(Address address,
125 Code* target,
126 ConstantPoolArray* constant_pool) {
81 ASSERT(target->is_inline_cache_stub() || target->is_compare_ic_stub()); 127 ASSERT(target->is_inline_cache_stub() || target->is_compare_ic_stub());
82 Heap* heap = target->GetHeap(); 128 Heap* heap = target->GetHeap();
83 Code* old_target = GetTargetAtAddress(address); 129 Code* old_target = GetTargetAtAddress(address, constant_pool);
84 #ifdef DEBUG 130 #ifdef DEBUG
85 // STORE_IC and KEYED_STORE_IC use Code::extra_ic_state() to mark 131 // STORE_IC and KEYED_STORE_IC use Code::extra_ic_state() to mark
86 // ICs as strict mode. The strict-ness of the IC must be preserved. 132 // ICs as strict mode. The strict-ness of the IC must be preserved.
87 if (old_target->kind() == Code::STORE_IC || 133 if (old_target->kind() == Code::STORE_IC ||
88 old_target->kind() == Code::KEYED_STORE_IC) { 134 old_target->kind() == Code::KEYED_STORE_IC) {
89 ASSERT(StoreIC::GetStrictMode(old_target->extra_ic_state()) == 135 ASSERT(StoreIC::GetStrictMode(old_target->extra_ic_state()) ==
90 StoreIC::GetStrictMode(target->extra_ic_state())); 136 StoreIC::GetStrictMode(target->extra_ic_state()));
91 } 137 }
92 #endif 138 #endif
93 Assembler::set_target_address_at(address, target->instruction_start()); 139 Assembler::set_target_address_at(
140 address, constant_pool, target->instruction_start());
94 if (heap->gc_state() == Heap::MARK_COMPACT) { 141 if (heap->gc_state() == Heap::MARK_COMPACT) {
95 heap->mark_compact_collector()->RecordCodeTargetPatch(address, target); 142 heap->mark_compact_collector()->RecordCodeTargetPatch(address, target);
96 } else { 143 } else {
97 heap->incremental_marking()->RecordCodeTargetPatch(address, target); 144 heap->incremental_marking()->RecordCodeTargetPatch(address, target);
98 } 145 }
99 PostPatching(address, target, old_target); 146 PostPatching(address, target, old_target);
100 } 147 }
101 148
102 149
103 InlineCacheHolderFlag IC::GetCodeCacheForObject(Object* object) { 150 InlineCacheHolderFlag IC::GetCodeCacheForObject(Object* object) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 196 }
150 return handle(JSObject::cast(constructor->instance_prototype())->map()); 197 return handle(JSObject::cast(constructor->instance_prototype())->map());
151 } 198 }
152 return TypeToMap(type, isolate); 199 return TypeToMap(type, isolate);
153 } 200 }
154 201
155 202
156 } } // namespace v8::internal 203 } } // namespace v8::internal
157 204
158 #endif // V8_IC_INL_H_ 205 #endif // V8_IC_INL_H_
OLDNEW
« no previous file with comments | « src/ic.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698