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 24 matching lines...) Expand all Loading... | |
35 #ifndef V8_ASSEMBLER_H_ | 35 #ifndef V8_ASSEMBLER_H_ |
36 #define V8_ASSEMBLER_H_ | 36 #define V8_ASSEMBLER_H_ |
37 | 37 |
38 #include "gdb-jit.h" | 38 #include "gdb-jit.h" |
39 #include "runtime.h" | 39 #include "runtime.h" |
40 #include "token.h" | 40 #include "token.h" |
41 | 41 |
42 namespace v8 { | 42 namespace v8 { |
43 namespace internal { | 43 namespace internal { |
44 | 44 |
45 | 45 const unsigned kNoASTId = -1; |
46 // ----------------------------------------------------------------------------- | 46 // ----------------------------------------------------------------------------- |
47 // Platform independent assembler base class. | 47 // Platform independent assembler base class. |
48 | 48 |
49 class AssemblerBase: public Malloced { | 49 class AssemblerBase: public Malloced { |
50 public: | 50 public: |
51 explicit AssemblerBase(Isolate* isolate) : isolate_(isolate) {} | 51 explicit AssemblerBase(Isolate* isolate) : isolate_(isolate) {} |
52 | 52 |
53 Isolate* isolate() const { return isolate_; } | 53 Isolate* isolate() const { return isolate_; } |
54 | 54 |
55 private: | 55 private: |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 static const int kMinRelocCommentSize = 3 + kPointerSize; | 202 static const int kMinRelocCommentSize = 3 + kPointerSize; |
203 | 203 |
204 // The maximum size for a call instruction including pc-jump. | 204 // The maximum size for a call instruction including pc-jump. |
205 static const int kMaxCallSize = 6; | 205 static const int kMaxCallSize = 6; |
206 | 206 |
207 // The maximum pc delta that will use the short encoding. | 207 // The maximum pc delta that will use the short encoding. |
208 static const int kMaxSmallPCDelta; | 208 static const int kMaxSmallPCDelta; |
209 | 209 |
210 enum Mode { | 210 enum Mode { |
211 // Please note the order is important (see IsCodeTarget, IsGCRelocMode). | 211 // Please note the order is important (see IsCodeTarget, IsGCRelocMode). |
212 CODE_TARGET, // Code target which is not any of the above. | |
213 CODE_TARGET_WITH_ID, | |
212 CONSTRUCT_CALL, // code target that is a call to a JavaScript constructor. | 214 CONSTRUCT_CALL, // code target that is a call to a JavaScript constructor. |
213 CODE_TARGET_CONTEXT, // Code target used for contextual loads and stores. | 215 CODE_TARGET_CONTEXT, // Code target used for contextual loads and stores. |
214 DEBUG_BREAK, // Code target for the debugger statement. | 216 DEBUG_BREAK, // Code target for the debugger statement. |
215 CODE_TARGET, // Code target which is not any of the above. | |
216 EMBEDDED_OBJECT, | 217 EMBEDDED_OBJECT, |
217 GLOBAL_PROPERTY_CELL, | 218 GLOBAL_PROPERTY_CELL, |
218 | 219 |
219 // Everything after runtime_entry (inclusive) is not GC'ed. | 220 // Everything after runtime_entry (inclusive) is not GC'ed. |
220 RUNTIME_ENTRY, | 221 RUNTIME_ENTRY, |
221 JS_RETURN, // Marks start of the ExitJSFrame code. | 222 JS_RETURN, // Marks start of the ExitJSFrame code. |
222 COMMENT, | 223 COMMENT, |
223 POSITION, // See comment for kNoPosition above. | 224 POSITION, // See comment for kNoPosition above. |
224 STATEMENT_POSITION, // See comment for kNoPosition above. | 225 STATEMENT_POSITION, // See comment for kNoPosition above. |
225 DEBUG_BREAK_SLOT, // Additional code inserted for debug break slot. | 226 DEBUG_BREAK_SLOT, // Additional code inserted for debug break slot. |
226 EXTERNAL_REFERENCE, // The address of an external C++ function. | 227 EXTERNAL_REFERENCE, // The address of an external C++ function. |
227 INTERNAL_REFERENCE, // An address inside the same function. | 228 INTERNAL_REFERENCE, // An address inside the same function. |
228 | 229 |
229 // add more as needed | 230 // add more as needed |
230 // Pseudo-types | 231 // Pseudo-types |
231 NUMBER_OF_MODES, // must be no greater than 14 - see RelocInfoWriter | 232 NUMBER_OF_MODES, // There are at most 14 modes with noncompact encoding. |
232 NONE, // never recorded | 233 NONE, // never recorded |
233 LAST_CODE_ENUM = CODE_TARGET, | 234 LAST_CODE_ENUM = DEBUG_BREAK, |
234 LAST_GCED_ENUM = GLOBAL_PROPERTY_CELL | 235 LAST_GCED_ENUM = EMBEDDED_OBJECT, |
Vitaly Repeshko
2011/04/15 01:24:43
I think GLOBAL_PROPERTY_CELL should stay the last
William Hesse
2011/04/15 11:51:27
Done.
| |
236 // Modes <= LAST_COMPACT_ENUM are guaranteed to have compact encoding. | |
237 LAST_COMPACT_ENUM = CODE_TARGET_WITH_ID | |
235 }; | 238 }; |
236 | 239 |
237 | 240 |
238 RelocInfo() {} | 241 RelocInfo() {} |
239 RelocInfo(byte* pc, Mode rmode, intptr_t data) | 242 RelocInfo(byte* pc, Mode rmode, intptr_t data) |
240 : pc_(pc), rmode_(rmode), data_(data) { | 243 : pc_(pc), rmode_(rmode), data_(data) { |
241 } | 244 } |
242 | 245 |
243 static inline bool IsConstructCall(Mode mode) { | 246 static inline bool IsConstructCall(Mode mode) { |
244 return mode == CONSTRUCT_CALL; | 247 return mode == CONSTRUCT_CALL; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
354 static const char* RelocModeName(Mode rmode); | 357 static const char* RelocModeName(Mode rmode); |
355 void Print(FILE* out); | 358 void Print(FILE* out); |
356 #endif // ENABLE_DISASSEMBLER | 359 #endif // ENABLE_DISASSEMBLER |
357 #ifdef DEBUG | 360 #ifdef DEBUG |
358 // Debugging | 361 // Debugging |
359 void Verify(); | 362 void Verify(); |
360 #endif | 363 #endif |
361 | 364 |
362 static const int kCodeTargetMask = (1 << (LAST_CODE_ENUM + 1)) - 1; | 365 static const int kCodeTargetMask = (1 << (LAST_CODE_ENUM + 1)) - 1; |
363 static const int kPositionMask = 1 << POSITION | 1 << STATEMENT_POSITION; | 366 static const int kPositionMask = 1 << POSITION | 1 << STATEMENT_POSITION; |
364 static const int kDebugMask = kPositionMask | 1 << COMMENT; | 367 static const int kDataMask = |
368 (1 << CODE_TARGET_WITH_ID) | kPositionMask | (1 << COMMENT); | |
365 static const int kApplyMask; // Modes affected by apply. Depends on arch. | 369 static const int kApplyMask; // Modes affected by apply. Depends on arch. |
366 | 370 |
367 private: | 371 private: |
368 // On ARM, note that pc_ is the address of the constant pool entry | 372 // On ARM, note that pc_ is the address of the constant pool entry |
369 // to be relocated and not the address of the instruction | 373 // to be relocated and not the address of the instruction |
370 // referencing the constant pool entry (except when rmode_ == | 374 // referencing the constant pool entry (except when rmode_ == |
371 // comment). | 375 // comment). |
372 byte* pc_; | 376 byte* pc_; |
373 Mode rmode_; | 377 Mode rmode_; |
374 intptr_t data_; | 378 intptr_t data_; |
375 friend class RelocIterator; | 379 friend class RelocIterator; |
376 }; | 380 }; |
377 | 381 |
378 | 382 |
379 // RelocInfoWriter serializes a stream of relocation info. It writes towards | 383 // RelocInfoWriter serializes a stream of relocation info. It writes towards |
380 // lower addresses. | 384 // lower addresses. |
381 class RelocInfoWriter BASE_EMBEDDED { | 385 class RelocInfoWriter BASE_EMBEDDED { |
382 public: | 386 public: |
383 RelocInfoWriter() : pos_(NULL), last_pc_(NULL), last_data_(0) {} | 387 RelocInfoWriter() : pos_(NULL), |
384 RelocInfoWriter(byte* pos, byte* pc) : pos_(pos), last_pc_(pc), | 388 last_pc_(NULL), |
385 last_data_(0) {} | 389 last_id_(0), |
390 last_position_(0) {} | |
391 RelocInfoWriter(byte* pos, byte* pc) : pos_(pos), | |
392 last_pc_(pc), | |
393 last_id_(0), | |
394 last_position_(0) {} | |
386 | 395 |
387 byte* pos() const { return pos_; } | 396 byte* pos() const { return pos_; } |
388 byte* last_pc() const { return last_pc_; } | 397 byte* last_pc() const { return last_pc_; } |
389 | 398 |
390 void Write(const RelocInfo* rinfo); | 399 void Write(const RelocInfo* rinfo); |
391 | 400 |
392 // Update the state of the stream after reloc info buffer | 401 // Update the state of the stream after reloc info buffer |
393 // and/or code is moved while the stream is active. | 402 // and/or code is moved while the stream is active. |
394 void Reposition(byte* pos, byte* pc) { | 403 void Reposition(byte* pos, byte* pc) { |
395 pos_ = pos; | 404 pos_ = pos; |
396 last_pc_ = pc; | 405 last_pc_ = pc; |
397 } | 406 } |
398 | 407 |
399 // Max size (bytes) of a written RelocInfo. Longest encoding is | 408 // Max size (bytes) of a written RelocInfo. Longest encoding is |
400 // ExtraTag, VariableLengthPCJump, ExtraTag, pc_delta, ExtraTag, data_delta. | 409 // ExtraTag, VariableLengthPCJump, ExtraTag, pc_delta, ExtraTag, data_delta. |
401 // On ia32 and arm this is 1 + 4 + 1 + 1 + 1 + 4 = 12. | 410 // On ia32 and arm this is 1 + 4 + 1 + 1 + 1 + 4 = 12. |
402 // On x64 this is 1 + 4 + 1 + 1 + 1 + 8 == 16; | 411 // On x64 this is 1 + 4 + 1 + 1 + 1 + 8 == 16; |
403 // Here we use the maximum of the two. | 412 // Here we use the maximum of the two. |
404 static const int kMaxSize = 16; | 413 static const int kMaxSize = 16; |
405 | 414 |
406 private: | 415 private: |
407 inline uint32_t WriteVariableLengthPCJump(uint32_t pc_delta); | 416 inline uint32_t WriteVariableLengthPCJump(uint32_t pc_delta); |
408 inline void WriteTaggedPC(uint32_t pc_delta, int tag); | 417 inline void WriteTaggedPC(uint32_t pc_delta, int tag); |
409 inline void WriteExtraTaggedPC(uint32_t pc_delta, int extra_tag); | 418 inline void WriteExtraTaggedPC(uint32_t pc_delta, int extra_tag); |
419 inline void WriteExtraTaggedIntData(int data_delta, int top_tag); | |
410 inline void WriteExtraTaggedData(intptr_t data_delta, int top_tag); | 420 inline void WriteExtraTaggedData(intptr_t data_delta, int top_tag); |
411 inline void WriteTaggedData(intptr_t data_delta, int tag); | 421 inline void WriteTaggedData(intptr_t data_delta, int tag); |
412 inline void WriteExtraTag(int extra_tag, int top_tag); | 422 inline void WriteExtraTag(int extra_tag, int top_tag); |
413 | 423 |
414 byte* pos_; | 424 byte* pos_; |
415 byte* last_pc_; | 425 byte* last_pc_; |
416 intptr_t last_data_; | 426 int last_id_; |
427 int last_position_; | |
417 DISALLOW_COPY_AND_ASSIGN(RelocInfoWriter); | 428 DISALLOW_COPY_AND_ASSIGN(RelocInfoWriter); |
418 }; | 429 }; |
419 | 430 |
420 | 431 |
421 // A RelocIterator iterates over relocation information. | 432 // A RelocIterator iterates over relocation information. |
422 // Typical use: | 433 // Typical use: |
423 // | 434 // |
424 // for (RelocIterator it(code); !it.done(); it.next()) { | 435 // for (RelocIterator it(code); !it.done(); it.next()) { |
425 // // do something with it.rinfo() here | 436 // // do something with it.rinfo() here |
426 // } | 437 // } |
(...skipping 21 matching lines...) Expand all Loading... | |
448 private: | 459 private: |
449 // Advance* moves the position before/after reading. | 460 // Advance* moves the position before/after reading. |
450 // *Read* reads from current byte(s) into rinfo_. | 461 // *Read* reads from current byte(s) into rinfo_. |
451 // *Get* just reads and returns info on current byte. | 462 // *Get* just reads and returns info on current byte. |
452 void Advance(int bytes = 1) { pos_ -= bytes; } | 463 void Advance(int bytes = 1) { pos_ -= bytes; } |
453 int AdvanceGetTag(); | 464 int AdvanceGetTag(); |
454 int GetExtraTag(); | 465 int GetExtraTag(); |
455 int GetTopTag(); | 466 int GetTopTag(); |
456 void ReadTaggedPC(); | 467 void ReadTaggedPC(); |
457 void AdvanceReadPC(); | 468 void AdvanceReadPC(); |
469 void AdvanceReadId(); | |
470 void AdvanceReadPosition(); | |
458 void AdvanceReadData(); | 471 void AdvanceReadData(); |
459 void AdvanceReadVariableLengthPCJump(); | 472 void AdvanceReadVariableLengthPCJump(); |
460 int GetPositionTypeTag(); | 473 int GetLocatableTypeTag(); |
461 void ReadTaggedData(); | 474 void ReadTaggedId(); |
462 | 475 void ReadTaggedPosition(); |
463 static RelocInfo::Mode DebugInfoModeFromTag(int tag); | |
464 | 476 |
465 // If the given mode is wanted, set it in rinfo_ and return true. | 477 // If the given mode is wanted, set it in rinfo_ and return true. |
466 // Else return false. Used for efficiently skipping unwanted modes. | 478 // Else return false. Used for efficiently skipping unwanted modes. |
467 bool SetMode(RelocInfo::Mode mode) { | 479 bool SetMode(RelocInfo::Mode mode) { |
468 return (mode_mask_ & (1 << mode)) ? (rinfo_.rmode_ = mode, true) : false; | 480 return (mode_mask_ & (1 << mode)) ? (rinfo_.rmode_ = mode, true) : false; |
469 } | 481 } |
470 | 482 |
471 byte* pos_; | 483 byte* pos_; |
472 byte* end_; | 484 byte* end_; |
473 RelocInfo rinfo_; | 485 RelocInfo rinfo_; |
474 bool done_; | 486 bool done_; |
475 int mode_mask_; | 487 int mode_mask_; |
488 int last_id_; | |
489 int last_position_; | |
476 DISALLOW_COPY_AND_ASSIGN(RelocIterator); | 490 DISALLOW_COPY_AND_ASSIGN(RelocIterator); |
477 }; | 491 }; |
478 | 492 |
479 | 493 |
480 //------------------------------------------------------------------------------ | 494 //------------------------------------------------------------------------------ |
481 // External function | 495 // External function |
482 | 496 |
483 //---------------------------------------------------------------------------- | 497 //---------------------------------------------------------------------------- |
484 class IC_Utility; | 498 class IC_Utility; |
485 class SCTableReference; | 499 class SCTableReference; |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
813 return num_bits_set; | 827 return num_bits_set; |
814 } | 828 } |
815 | 829 |
816 // Computes pow(x, y) with the special cases in the spec for Math.pow. | 830 // Computes pow(x, y) with the special cases in the spec for Math.pow. |
817 double power_double_int(double x, int y); | 831 double power_double_int(double x, int y); |
818 double power_double_double(double x, double y); | 832 double power_double_double(double x, double y); |
819 | 833 |
820 } } // namespace v8::internal | 834 } } // namespace v8::internal |
821 | 835 |
822 #endif // V8_ASSEMBLER_H_ | 836 #endif // V8_ASSEMBLER_H_ |
OLD | NEW |