| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_IC_INL_H_ | 5 #ifndef V8_IC_INL_H_ |
| 6 #define V8_IC_INL_H_ | 6 #define V8_IC_INL_H_ |
| 7 | 7 |
| 8 #include "src/ic/ic.h" | 8 #include "src/ic/ic.h" |
| 9 | 9 |
| 10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
| 11 #include "src/debug.h" | 11 #include "src/debug.h" |
| 12 #include "src/macro-assembler.h" | 12 #include "src/macro-assembler.h" |
| 13 #include "src/prototype.h" | 13 #include "src/prototype.h" |
| 14 | 14 |
| 15 namespace v8 { | 15 namespace v8 { |
| 16 namespace internal { | 16 namespace internal { |
| 17 | 17 |
| 18 | 18 |
| 19 Address IC::address() const { | 19 Address IC::address() const { |
| 20 // Get the address of the call. | 20 // Get the address of the call. |
| 21 Address result = Assembler::target_address_from_return_address(pc()); | 21 return Assembler::target_address_from_return_address(pc()); |
| 22 | |
| 23 Debug* debug = isolate()->debug(); | |
| 24 // First check if any break points are active if not just return the address | |
| 25 // of the call. | |
| 26 if (!debug->has_break_points()) return result; | |
| 27 | |
| 28 // At least one break point is active perform additional test to ensure that | |
| 29 // break point locations are updated correctly. | |
| 30 if (debug->IsDebugBreak( | |
| 31 Assembler::target_address_at(result, raw_constant_pool()))) { | |
| 32 // If the call site is a call to debug break then return the address in | |
| 33 // the original code instead of the address in the running code. This will | |
| 34 // cause the original code to be updated and keeps the breakpoint active in | |
| 35 // the running code. | |
| 36 Code* code = GetCode(); | |
| 37 Code* original_code = GetOriginalCode(); | |
| 38 intptr_t delta = | |
| 39 original_code->instruction_start() - code->instruction_start(); | |
| 40 // Return the address in the original code. This is the place where | |
| 41 // the call which has been overwritten by the DebugBreakXXX resides | |
| 42 // and the place where the inline cache system should look. | |
| 43 return result + delta; | |
| 44 } else { | |
| 45 // No break point here just return the address of the call. | |
| 46 return result; | |
| 47 } | |
| 48 } | 22 } |
| 49 | 23 |
| 50 | 24 |
| 51 Address IC::constant_pool() const { | 25 Address IC::constant_pool() const { |
| 52 if (!FLAG_enable_embedded_constant_pool) { | 26 if (FLAG_enable_embedded_constant_pool) { |
| 27 return raw_constant_pool(); |
| 28 } else { |
| 53 return NULL; | 29 return NULL; |
| 54 } else { | |
| 55 Address constant_pool = raw_constant_pool(); | |
| 56 Debug* debug = isolate()->debug(); | |
| 57 // First check if any break points are active if not just return the | |
| 58 // original constant pool. | |
| 59 if (!debug->has_break_points()) return constant_pool; | |
| 60 | |
| 61 // At least one break point is active perform additional test to ensure that | |
| 62 // break point locations are updated correctly. | |
| 63 Address target = Assembler::target_address_from_return_address(pc()); | |
| 64 if (debug->IsDebugBreak( | |
| 65 Assembler::target_address_at(target, constant_pool))) { | |
| 66 // If the call site is a call to debug break then we want to return the | |
| 67 // constant pool for the original code instead of the breakpointed code. | |
| 68 return GetOriginalCode()->constant_pool(); | |
| 69 } | |
| 70 return constant_pool; | |
| 71 } | 30 } |
| 72 } | 31 } |
| 73 | 32 |
| 74 | 33 |
| 75 Address IC::raw_constant_pool() const { | 34 Address IC::raw_constant_pool() const { |
| 76 if (FLAG_enable_embedded_constant_pool) { | 35 if (FLAG_enable_embedded_constant_pool) { |
| 77 return *constant_pool_address_; | 36 return *constant_pool_address_; |
| 78 } else { | 37 } else { |
| 79 return NULL; | 38 return NULL; |
| 80 } | 39 } |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 bool IC::AddressIsDeoptimizedCode(Isolate* isolate, Address address) { | 192 bool IC::AddressIsDeoptimizedCode(Isolate* isolate, Address address) { |
| 234 Code* host = | 193 Code* host = |
| 235 isolate->inner_pointer_to_code_cache()->GetCacheEntry(address)->code; | 194 isolate->inner_pointer_to_code_cache()->GetCacheEntry(address)->code; |
| 236 return (host->kind() == Code::OPTIMIZED_FUNCTION && | 195 return (host->kind() == Code::OPTIMIZED_FUNCTION && |
| 237 host->marked_for_deoptimization()); | 196 host->marked_for_deoptimization()); |
| 238 } | 197 } |
| 239 } | 198 } |
| 240 } // namespace v8::internal | 199 } // namespace v8::internal |
| 241 | 200 |
| 242 #endif // V8_IC_INL_H_ | 201 #endif // V8_IC_INL_H_ |
| OLD | NEW |