OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 20 matching lines...) Expand all Loading... |
31 // The original source code covered by the above license above has been | 31 // The original source code covered by the above license above has been |
32 // modified significantly by Google Inc. | 32 // modified significantly by Google Inc. |
33 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 33 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
34 | 34 |
35 #ifndef V8_ASSEMBLER_H_ | 35 #ifndef V8_ASSEMBLER_H_ |
36 #define V8_ASSEMBLER_H_ | 36 #define V8_ASSEMBLER_H_ |
37 | 37 |
38 #include "runtime.h" | 38 #include "runtime.h" |
39 #include "top.h" | 39 #include "top.h" |
40 #include "token.h" | 40 #include "token.h" |
| 41 #include "objects.h" |
41 | 42 |
42 namespace v8 { | 43 namespace v8 { |
43 namespace internal { | 44 namespace internal { |
44 | 45 |
45 | 46 |
46 // ----------------------------------------------------------------------------- | 47 // ----------------------------------------------------------------------------- |
47 // Labels represent pc locations; they are typically jump or call targets. | 48 // Labels represent pc locations; they are typically jump or call targets. |
48 // After declaration, a label can be freely used to denote known or (yet) | 49 // After declaration, a label can be freely used to denote known or (yet) |
49 // unknown pc location. Assembler::bind() is used to bind a label to the | 50 // unknown pc location. Assembler::bind() is used to bind a label to the |
50 // current pc. A label can be bound only once. | 51 // current pc. A label can be bound only once. |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 // Read/modify the code target in the branch/call instruction | 193 // Read/modify the code target in the branch/call instruction |
193 // this relocation applies to; | 194 // this relocation applies to; |
194 // can only be called if IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY | 195 // can only be called if IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY |
195 INLINE(Address target_address()); | 196 INLINE(Address target_address()); |
196 INLINE(void set_target_address(Address target)); | 197 INLINE(void set_target_address(Address target)); |
197 INLINE(Object* target_object()); | 198 INLINE(Object* target_object()); |
198 INLINE(Handle<Object> target_object_handle(Assembler* origin)); | 199 INLINE(Handle<Object> target_object_handle(Assembler* origin)); |
199 INLINE(Object** target_object_address()); | 200 INLINE(Object** target_object_address()); |
200 INLINE(void set_target_object(Object* target)); | 201 INLINE(void set_target_object(Object* target)); |
201 | 202 |
202 // Read the address of the word containing the target_address. Can only | 203 // Read the address of the word containing the target_address in an |
203 // be called if IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY. | 204 // instruction stream. What this means exactly is architecture-independent. |
| 205 // The only architecture-independent user of this function is the serializer. |
| 206 // The serializer uses it to find out how many raw bytes of instruction to |
| 207 // output before the next target. Architecture-independent code shouldn't |
| 208 // dereference the pointer it gets back from this. |
204 INLINE(Address target_address_address()); | 209 INLINE(Address target_address_address()); |
| 210 // This indicates how much space a target takes up when deserializing a code |
| 211 // stream. For most architectures this is just the size of a pointer. For |
| 212 // an instruction like movw/movt where the target bits are mixed into the |
| 213 // instruction bits the size of the target will be zero, indicating that the |
| 214 // serializer should not step forwards in memory after a target is resolved |
| 215 // and written. In this case the target_address_address function above |
| 216 // should return the end of the instructions to be patched, allowing the |
| 217 // deserializer to deserialize the instructions as raw bytes and put them in |
| 218 // place, ready to be patched with the target. |
| 219 INLINE(int target_address_size()); |
205 | 220 |
206 // Read/modify the reference in the instruction this relocation | 221 // Read/modify the reference in the instruction this relocation |
207 // applies to; can only be called if rmode_ is external_reference | 222 // applies to; can only be called if rmode_ is external_reference |
208 INLINE(Address* target_reference_address()); | 223 INLINE(Address* target_reference_address()); |
209 | 224 |
210 // Read/modify the address of a call instruction. This is used to relocate | 225 // Read/modify the address of a call instruction. This is used to relocate |
211 // the break points where straight-line code is patched with a call | 226 // the break points where straight-line code is patched with a call |
212 // instruction. | 227 // instruction. |
213 INLINE(Address call_address()); | 228 INLINE(Address call_address()); |
214 INLINE(void set_call_address(Address target)); | 229 INLINE(void set_call_address(Address target)); |
215 INLINE(Object* call_object()); | 230 INLINE(Object* call_object()); |
216 INLINE(Object** call_object_address()); | 231 INLINE(Object** call_object_address()); |
217 INLINE(void set_call_object(Object* target)); | 232 INLINE(void set_call_object(Object* target)); |
218 | 233 |
| 234 inline void Visit(ObjectVisitor* v); |
| 235 |
219 // Patch the code with some other code. | 236 // Patch the code with some other code. |
220 void PatchCode(byte* instructions, int instruction_count); | 237 void PatchCode(byte* instructions, int instruction_count); |
221 | 238 |
222 // Patch the code with a call. | 239 // Patch the code with a call. |
223 void PatchCodeWithCall(Address target, int guard_bytes); | 240 void PatchCodeWithCall(Address target, int guard_bytes); |
224 | 241 |
225 // Check whether this return sequence has been patched | 242 // Check whether this return sequence has been patched |
226 // with a call to the debugger. | 243 // with a call to the debugger. |
227 INLINE(bool IsPatchedReturnSequence()); | 244 INLINE(bool IsPatchedReturnSequence()); |
228 | 245 |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 unsigned int num_bits_set; | 556 unsigned int num_bits_set; |
540 for (num_bits_set = 0; x; x >>= 1) { | 557 for (num_bits_set = 0; x; x >>= 1) { |
541 num_bits_set += x & 1; | 558 num_bits_set += x & 1; |
542 } | 559 } |
543 return num_bits_set; | 560 return num_bits_set; |
544 } | 561 } |
545 | 562 |
546 } } // namespace v8::internal | 563 } } // namespace v8::internal |
547 | 564 |
548 #endif // V8_ASSEMBLER_H_ | 565 #endif // V8_ASSEMBLER_H_ |
OLD | NEW |