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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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()))) { | |
55 // If the call site is a call to debug break then return the address in | 54 // If the call site is a call to debug break then return the address in |
56 // the original code instead of the address in the running code. This will | 55 // the original code instead of the address in the running code. This will |
57 // cause the original code to be updated and keeps the breakpoint active in | 56 // cause the original code to be updated and keeps the breakpoint active in |
58 // the running code. | 57 // the running code. |
59 Code* code = GetCode(); | 58 return OriginalCodeAddress(); |
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; | |
67 } else { | 59 } else { |
68 // No break point here just return the address of the call. | 60 // No break point here just return the address of the call. |
69 return result; | 61 return result; |
70 } | 62 } |
71 #else | 63 #else |
72 return result; | 64 return result; |
73 #endif | 65 #endif |
74 } | 66 } |
75 | 67 |
76 | 68 |
77 ConstantPoolArray* IC::constant_pool() const { | 69 Code* IC::GetTargetAtAddress(Address address) { |
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) { | |
114 // Get the target address of the IC. | 70 // Get the target address of the IC. |
115 Address target = Assembler::target_address_at(address, constant_pool); | 71 Address target = Assembler::target_address_at(address); |
116 // Convert target address to the code object. Code::GetCodeFromTargetAddress | 72 // Convert target address to the code object. Code::GetCodeFromTargetAddress |
117 // is safe for use during GC where the map might be marked. | 73 // is safe for use during GC where the map might be marked. |
118 Code* result = Code::GetCodeFromTargetAddress(target); | 74 Code* result = Code::GetCodeFromTargetAddress(target); |
119 ASSERT(result->is_inline_cache_stub()); | 75 ASSERT(result->is_inline_cache_stub()); |
120 return result; | 76 return result; |
121 } | 77 } |
122 | 78 |
123 | 79 |
124 void IC::SetTargetAtAddress(Address address, | 80 void IC::SetTargetAtAddress(Address address, Code* target) { |
125 Code* target, | |
126 ConstantPoolArray* constant_pool) { | |
127 ASSERT(target->is_inline_cache_stub() || target->is_compare_ic_stub()); | 81 ASSERT(target->is_inline_cache_stub() || target->is_compare_ic_stub()); |
128 Heap* heap = target->GetHeap(); | 82 Heap* heap = target->GetHeap(); |
129 Code* old_target = GetTargetAtAddress(address, constant_pool); | 83 Code* old_target = GetTargetAtAddress(address); |
130 #ifdef DEBUG | 84 #ifdef DEBUG |
131 // STORE_IC and KEYED_STORE_IC use Code::extra_ic_state() to mark | 85 // STORE_IC and KEYED_STORE_IC use Code::extra_ic_state() to mark |
132 // ICs as strict mode. The strict-ness of the IC must be preserved. | 86 // ICs as strict mode. The strict-ness of the IC must be preserved. |
133 if (old_target->kind() == Code::STORE_IC || | 87 if (old_target->kind() == Code::STORE_IC || |
134 old_target->kind() == Code::KEYED_STORE_IC) { | 88 old_target->kind() == Code::KEYED_STORE_IC) { |
135 ASSERT(StoreIC::GetStrictMode(old_target->extra_ic_state()) == | 89 ASSERT(StoreIC::GetStrictMode(old_target->extra_ic_state()) == |
136 StoreIC::GetStrictMode(target->extra_ic_state())); | 90 StoreIC::GetStrictMode(target->extra_ic_state())); |
137 } | 91 } |
138 #endif | 92 #endif |
139 Assembler::set_target_address_at( | 93 Assembler::set_target_address_at(address, target->instruction_start()); |
140 address, constant_pool, target->instruction_start()); | |
141 if (heap->gc_state() == Heap::MARK_COMPACT) { | 94 if (heap->gc_state() == Heap::MARK_COMPACT) { |
142 heap->mark_compact_collector()->RecordCodeTargetPatch(address, target); | 95 heap->mark_compact_collector()->RecordCodeTargetPatch(address, target); |
143 } else { | 96 } else { |
144 heap->incremental_marking()->RecordCodeTargetPatch(address, target); | 97 heap->incremental_marking()->RecordCodeTargetPatch(address, target); |
145 } | 98 } |
146 PostPatching(address, target, old_target); | 99 PostPatching(address, target, old_target); |
147 } | 100 } |
148 | 101 |
149 | 102 |
150 InlineCacheHolderFlag IC::GetCodeCacheForObject(Object* object) { | 103 InlineCacheHolderFlag IC::GetCodeCacheForObject(Object* object) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 } | 149 } |
197 return handle(JSObject::cast(constructor->instance_prototype())->map()); | 150 return handle(JSObject::cast(constructor->instance_prototype())->map()); |
198 } | 151 } |
199 return TypeToMap(type, isolate); | 152 return TypeToMap(type, isolate); |
200 } | 153 } |
201 | 154 |
202 | 155 |
203 } } // namespace v8::internal | 156 } } // namespace v8::internal |
204 | 157 |
205 #endif // V8_IC_INL_H_ | 158 #endif // V8_IC_INL_H_ |
OLD | NEW |