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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 enum Mode { | 388 enum Mode { |
389 // Please note the order is important (see IsCodeTarget, IsGCRelocMode). | 389 // Please note the order is important (see IsCodeTarget, IsGCRelocMode). |
390 CODE_TARGET, // Code target which is not any of the above. | 390 CODE_TARGET, // Code target which is not any of the above. |
391 CODE_TARGET_WITH_ID, | 391 CODE_TARGET_WITH_ID, |
392 DEBUGGER_STATEMENT, // Code target for the debugger statement. | 392 DEBUGGER_STATEMENT, // Code target for the debugger statement. |
393 EMBEDDED_OBJECT, | 393 EMBEDDED_OBJECT, |
394 // To relocate pointers into the wasm memory embedded in wasm code | 394 // To relocate pointers into the wasm memory embedded in wasm code |
395 WASM_MEMORY_REFERENCE, | 395 WASM_MEMORY_REFERENCE, |
396 WASM_GLOBAL_REFERENCE, | 396 WASM_GLOBAL_REFERENCE, |
397 WASM_MEMORY_SIZE_REFERENCE, | 397 WASM_MEMORY_SIZE_REFERENCE, |
| 398 WASM_FUNCTION_TABLE_SIZE_REFERENCE, |
398 CELL, | 399 CELL, |
399 | 400 |
400 // Everything after runtime_entry (inclusive) is not GC'ed. | 401 // Everything after runtime_entry (inclusive) is not GC'ed. |
401 RUNTIME_ENTRY, | 402 RUNTIME_ENTRY, |
402 COMMENT, | 403 COMMENT, |
403 | 404 |
404 // Additional code inserted for debug break slot. | 405 // Additional code inserted for debug break slot. |
405 DEBUG_BREAK_SLOT_AT_POSITION, | 406 DEBUG_BREAK_SLOT_AT_POSITION, |
406 DEBUG_BREAK_SLOT_AT_RETURN, | 407 DEBUG_BREAK_SLOT_AT_RETURN, |
407 DEBUG_BREAK_SLOT_AT_CALL, | 408 DEBUG_BREAK_SLOT_AT_CALL, |
(...skipping 22 matching lines...) Expand all Loading... |
430 // Pseudo-types | 431 // Pseudo-types |
431 NUMBER_OF_MODES, | 432 NUMBER_OF_MODES, |
432 NONE32, // never recorded 32-bit value | 433 NONE32, // never recorded 32-bit value |
433 NONE64, // never recorded 64-bit value | 434 NONE64, // never recorded 64-bit value |
434 CODE_AGE_SEQUENCE, // Not stored in RelocInfo array, used explictly by | 435 CODE_AGE_SEQUENCE, // Not stored in RelocInfo array, used explictly by |
435 // code aging. | 436 // code aging. |
436 | 437 |
437 FIRST_REAL_RELOC_MODE = CODE_TARGET, | 438 FIRST_REAL_RELOC_MODE = CODE_TARGET, |
438 LAST_REAL_RELOC_MODE = VENEER_POOL, | 439 LAST_REAL_RELOC_MODE = VENEER_POOL, |
439 LAST_CODE_ENUM = DEBUGGER_STATEMENT, | 440 LAST_CODE_ENUM = DEBUGGER_STATEMENT, |
440 LAST_GCED_ENUM = WASM_MEMORY_SIZE_REFERENCE, | 441 LAST_GCED_ENUM = WASM_FUNCTION_TABLE_SIZE_REFERENCE, |
441 FIRST_SHAREABLE_RELOC_MODE = CELL, | 442 FIRST_SHAREABLE_RELOC_MODE = CELL, |
442 }; | 443 }; |
443 | 444 |
444 STATIC_ASSERT(NUMBER_OF_MODES <= kBitsPerInt); | 445 STATIC_ASSERT(NUMBER_OF_MODES <= kBitsPerInt); |
445 | 446 |
446 explicit RelocInfo(Isolate* isolate) : isolate_(isolate) { | 447 explicit RelocInfo(Isolate* isolate) : isolate_(isolate) { |
447 DCHECK_NOT_NULL(isolate); | 448 DCHECK_NOT_NULL(isolate); |
448 } | 449 } |
449 | 450 |
450 RelocInfo(Isolate* isolate, byte* pc, Mode rmode, intptr_t data, Code* host) | 451 RelocInfo(Isolate* isolate, byte* pc, Mode rmode, intptr_t data, Code* host) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 } | 524 } |
524 static inline bool IsWasmMemoryReference(Mode mode) { | 525 static inline bool IsWasmMemoryReference(Mode mode) { |
525 return mode == WASM_MEMORY_REFERENCE; | 526 return mode == WASM_MEMORY_REFERENCE; |
526 } | 527 } |
527 static inline bool IsWasmMemorySizeReference(Mode mode) { | 528 static inline bool IsWasmMemorySizeReference(Mode mode) { |
528 return mode == WASM_MEMORY_SIZE_REFERENCE; | 529 return mode == WASM_MEMORY_SIZE_REFERENCE; |
529 } | 530 } |
530 static inline bool IsWasmGlobalReference(Mode mode) { | 531 static inline bool IsWasmGlobalReference(Mode mode) { |
531 return mode == WASM_GLOBAL_REFERENCE; | 532 return mode == WASM_GLOBAL_REFERENCE; |
532 } | 533 } |
| 534 static inline bool IsWasmFunctionTableSizeReference(Mode mode) { |
| 535 return mode == WASM_FUNCTION_TABLE_SIZE_REFERENCE; |
| 536 } |
| 537 static inline bool IsWasmReference(Mode mode) { |
| 538 return mode == WASM_MEMORY_REFERENCE || mode == WASM_GLOBAL_REFERENCE || |
| 539 mode == WASM_MEMORY_SIZE_REFERENCE || |
| 540 mode == WASM_FUNCTION_TABLE_SIZE_REFERENCE; |
| 541 } |
| 542 static inline bool IsWasmSizeReference(Mode mode) { |
| 543 return mode == WASM_MEMORY_SIZE_REFERENCE || |
| 544 mode == WASM_FUNCTION_TABLE_SIZE_REFERENCE; |
| 545 } |
| 546 static inline bool IsWasmPtrReference(Mode mode) { |
| 547 return mode == WASM_MEMORY_REFERENCE || mode == WASM_GLOBAL_REFERENCE; |
| 548 } |
| 549 |
533 static inline int ModeMask(Mode mode) { return 1 << mode; } | 550 static inline int ModeMask(Mode mode) { return 1 << mode; } |
534 | 551 |
535 // Accessors | 552 // Accessors |
536 Isolate* isolate() const { return isolate_; } | 553 Isolate* isolate() const { return isolate_; } |
537 byte* pc() const { return pc_; } | 554 byte* pc() const { return pc_; } |
538 void set_pc(byte* pc) { pc_ = pc; } | 555 void set_pc(byte* pc) { pc_ = pc; } |
539 Mode rmode() const { return rmode_; } | 556 Mode rmode() const { return rmode_; } |
540 intptr_t data() const { return data_; } | 557 intptr_t data() const { return data_; } |
541 Code* host() const { return host_; } | 558 Code* host() const { return host_; } |
542 void set_host(Code* host) { host_ = host; } | 559 void set_host(Code* host) { host_ = host; } |
543 | 560 |
544 // Apply a relocation by delta bytes. When the code object is moved, PC | 561 // Apply a relocation by delta bytes. When the code object is moved, PC |
545 // relative addresses have to be updated as well as absolute addresses | 562 // relative addresses have to be updated as well as absolute addresses |
546 // inside the code (internal references). | 563 // inside the code (internal references). |
547 // Do not forget to flush the icache afterwards! | 564 // Do not forget to flush the icache afterwards! |
548 INLINE(void apply(intptr_t delta)); | 565 INLINE(void apply(intptr_t delta)); |
549 | 566 |
550 // Is the pointer this relocation info refers to coded like a plain pointer | 567 // Is the pointer this relocation info refers to coded like a plain pointer |
551 // or is it strange in some way (e.g. relative or patched into a series of | 568 // or is it strange in some way (e.g. relative or patched into a series of |
552 // instructions). | 569 // instructions). |
553 bool IsCodedSpecially(); | 570 bool IsCodedSpecially(); |
554 | 571 |
555 // If true, the pointer this relocation info refers to is an entry in the | 572 // If true, the pointer this relocation info refers to is an entry in the |
556 // constant pool, otherwise the pointer is embedded in the instruction stream. | 573 // constant pool, otherwise the pointer is embedded in the instruction stream. |
557 bool IsInConstantPool(); | 574 bool IsInConstantPool(); |
558 | 575 |
559 Address wasm_memory_reference(); | 576 Address wasm_memory_reference(); |
560 Address wasm_global_reference(); | 577 Address wasm_global_reference(); |
| 578 uint32_t wasm_function_table_size_reference(); |
561 uint32_t wasm_memory_size_reference(); | 579 uint32_t wasm_memory_size_reference(); |
562 void update_wasm_memory_reference( | 580 void update_wasm_memory_reference( |
563 Address old_base, Address new_base, uint32_t old_size, uint32_t new_size, | 581 Address old_base, Address new_base, uint32_t old_size, uint32_t new_size, |
564 ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); | 582 ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); |
565 void update_wasm_global_reference( | 583 void update_wasm_global_reference( |
566 Address old_base, Address new_base, | 584 Address old_base, Address new_base, |
567 ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); | 585 ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); |
| 586 void update_wasm_function_table_size_reference( |
| 587 uint32_t old_base, uint32_t new_base, |
| 588 ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); |
568 void set_target_address( | 589 void set_target_address( |
569 Address target, | 590 Address target, |
570 WriteBarrierMode write_barrier_mode = UPDATE_WRITE_BARRIER, | 591 WriteBarrierMode write_barrier_mode = UPDATE_WRITE_BARRIER, |
571 ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); | 592 ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); |
572 | 593 |
573 // this relocation applies to; | 594 // this relocation applies to; |
574 // can only be called if IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) | 595 // can only be called if IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) |
575 INLINE(Address target_address()); | 596 INLINE(Address target_address()); |
576 INLINE(Object* target_object()); | 597 INLINE(Object* target_object()); |
577 INLINE(Handle<Object> target_object_handle(Assembler* origin)); | 598 INLINE(Handle<Object> target_object_handle(Assembler* origin)); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 static const int kCodeTargetMask = (1 << (LAST_CODE_ENUM + 1)) - 1; | 687 static const int kCodeTargetMask = (1 << (LAST_CODE_ENUM + 1)) - 1; |
667 static const int kDataMask = (1 << CODE_TARGET_WITH_ID) | (1 << COMMENT); | 688 static const int kDataMask = (1 << CODE_TARGET_WITH_ID) | (1 << COMMENT); |
668 static const int kDebugBreakSlotMask = 1 << DEBUG_BREAK_SLOT_AT_POSITION | | 689 static const int kDebugBreakSlotMask = 1 << DEBUG_BREAK_SLOT_AT_POSITION | |
669 1 << DEBUG_BREAK_SLOT_AT_RETURN | | 690 1 << DEBUG_BREAK_SLOT_AT_RETURN | |
670 1 << DEBUG_BREAK_SLOT_AT_CALL; | 691 1 << DEBUG_BREAK_SLOT_AT_CALL; |
671 static const int kApplyMask; // Modes affected by apply. Depends on arch. | 692 static const int kApplyMask; // Modes affected by apply. Depends on arch. |
672 | 693 |
673 private: | 694 private: |
674 void unchecked_update_wasm_memory_reference(Address address, | 695 void unchecked_update_wasm_memory_reference(Address address, |
675 ICacheFlushMode flush_mode); | 696 ICacheFlushMode flush_mode); |
676 void unchecked_update_wasm_memory_size(uint32_t size, | 697 void unchecked_update_wasm_size(uint32_t size, ICacheFlushMode flush_mode); |
677 ICacheFlushMode flush_mode); | |
678 | 698 |
679 Isolate* isolate_; | 699 Isolate* isolate_; |
680 // On ARM, note that pc_ is the address of the constant pool entry | 700 // On ARM, note that pc_ is the address of the constant pool entry |
681 // to be relocated and not the address of the instruction | 701 // to be relocated and not the address of the instruction |
682 // referencing the constant pool entry (except when rmode_ == | 702 // referencing the constant pool entry (except when rmode_ == |
683 // comment). | 703 // comment). |
684 byte* pc_; | 704 byte* pc_; |
685 Mode rmode_; | 705 Mode rmode_; |
686 intptr_t data_; | 706 intptr_t data_; |
687 Code* host_; | 707 Code* host_; |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 std::vector<ConstantPoolEntry> shared_entries; | 1305 std::vector<ConstantPoolEntry> shared_entries; |
1286 }; | 1306 }; |
1287 | 1307 |
1288 Label emitted_label_; // Records pc_offset of emitted pool | 1308 Label emitted_label_; // Records pc_offset of emitted pool |
1289 PerTypeEntryInfo info_[ConstantPoolEntry::NUMBER_OF_TYPES]; | 1309 PerTypeEntryInfo info_[ConstantPoolEntry::NUMBER_OF_TYPES]; |
1290 }; | 1310 }; |
1291 | 1311 |
1292 } // namespace internal | 1312 } // namespace internal |
1293 } // namespace v8 | 1313 } // namespace v8 |
1294 #endif // V8_ASSEMBLER_H_ | 1314 #endif // V8_ASSEMBLER_H_ |
OLD | NEW |