OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // the running code. | 52 // the running code. |
53 return OriginalCodeAddress(); | 53 return OriginalCodeAddress(); |
54 } else { | 54 } else { |
55 // No break point here just return the address of the call. | 55 // No break point here just return the address of the call. |
56 return result; | 56 return result; |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 | 60 |
61 Code* IC::GetTargetAtAddress(Address address) { | 61 Code* IC::GetTargetAtAddress(Address address) { |
| 62 // Get the target address of the IC. |
62 Address target = Assembler::target_address_at(address); | 63 Address target = Assembler::target_address_at(address); |
63 HeapObject* code = HeapObject::FromAddress(target - Code::kHeaderSize); | 64 // Convert target address to the code object. Code::GetCodeFromTargetAddress |
64 // GetTargetAtAddress is called from IC::Clear which in turn is | 65 // is safe for use during GC where the map might be marked. |
65 // called when marking objects during mark sweep. reinterpret_cast | 66 Code* result = Code::GetCodeFromTargetAddress(target); |
66 // is therefore used instead of the more appropriate | |
67 // Code::cast. Code::cast does not work when the object's map is | |
68 // marked. | |
69 Code* result = reinterpret_cast<Code*>(code); | |
70 ASSERT(result->is_inline_cache_stub()); | 67 ASSERT(result->is_inline_cache_stub()); |
71 return result; | 68 return result; |
72 } | 69 } |
73 | 70 |
74 | 71 |
75 void IC::SetTargetAtAddress(Address address, Code* target) { | 72 void IC::SetTargetAtAddress(Address address, Code* target) { |
76 ASSERT(target->is_inline_cache_stub()); | 73 ASSERT(target->is_inline_cache_stub()); |
77 Assembler::set_target_address_at(address, target->instruction_start()); | 74 Assembler::set_target_address_at(address, target->instruction_start()); |
78 } | 75 } |
79 | 76 |
80 | 77 |
81 Map* IC::GetCodeCacheMapForObject(Object* object) { | 78 Map* IC::GetCodeCacheMapForObject(Object* object) { |
82 if (object->IsJSObject()) return JSObject::cast(object)->map(); | 79 if (object->IsJSObject()) return JSObject::cast(object)->map(); |
83 // If the object is a value, we use the prototype map for the cache. | 80 // If the object is a value, we use the prototype map for the cache. |
84 ASSERT(object->IsString() || object->IsNumber() || object->IsBoolean()); | 81 ASSERT(object->IsString() || object->IsNumber() || object->IsBoolean()); |
85 return JSObject::cast(object->GetPrototype())->map(); | 82 return JSObject::cast(object->GetPrototype())->map(); |
86 } | 83 } |
87 | 84 |
88 | 85 |
89 } } // namespace v8::internal | 86 } } // namespace v8::internal |
90 | 87 |
91 #endif // V8_IC_INL_H_ | 88 #endif // V8_IC_INL_H_ |
OLD | NEW |