35 #ifndef V8_ASSEMBLER_H_
36 #define V8_ASSEMBLER_H_
97 INLINE(
void UnuseNear()) { near_link_pos_ = 0; }
99 INLINE(
bool is_bound()
const) {
return pos_ < 0; }
100 INLINE(
bool is_unused()
const) {
return pos_ == 0 && near_link_pos_ == 0; }
101 INLINE(
bool is_linked()
const) {
return pos_ > 0; }
102 INLINE(
bool is_near_linked()
const) {
return near_link_pos_ > 0; }
121 void bind_to(
int pos) {
125 void link_to(
int pos, Distance distance = kFar) {
126 if (distance == kNear) {
127 near_link_pos_ = pos + 1;
135 friend class Assembler;
136 friend class RegexpAssembler;
137 friend class Displacement;
138 friend class RegExpMacroAssemblerIrregexp;
167 static const int kNoPosition = -1;
181 static const int kMaxCallSize = 6;
215 LAST_GCED_ENUM = GLOBAL_PROPERTY_CELL,
217 LAST_COMPACT_ENUM = CODE_TARGET_WITH_ID,
218 LAST_STANDARD_NONCOMPACT_ENUM = INTERNAL_REFERENCE
225 : pc_(pc), rmode_(rmode), data_(data), host_(host) {
229 return mode == CONSTRUCT_CALL;
232 return mode <= LAST_CODE_ENUM;
235 return mode == EMBEDDED_OBJECT;
239 return mode <= LAST_GCED_ENUM;
242 return mode == JS_RETURN;
245 return mode == COMMENT;
248 return mode == CONST_POOL;
251 return mode == POSITION || mode == STATEMENT_POSITION;
254 return mode == STATEMENT_POSITION;
257 return mode == EXTERNAL_REFERENCE;
260 return mode == INTERNAL_REFERENCE;
263 return mode == DEBUG_BREAK_SLOT;
271 intptr_t
data()
const {
return data_; }
275 INLINE(
void apply(intptr_t delta));
280 bool IsCodedSpecially();
315 INLINE(
int target_address_size());
330 template<
typename StaticVisitor>
inline void Visit(
Heap* heap);
331 inline void Visit(ObjectVisitor* v);
337 void PatchCodeWithCall(
Address target,
int guard_bytes);
341 INLINE(
bool IsPatchedReturnSequence());
345 INLINE(
bool IsPatchedDebugBreakSlotSequence());
347 #ifdef ENABLE_DISASSEMBLER
349 static const char* RelocModeName(Mode rmode);
350 void Print(FILE* out);
351 #endif // ENABLE_DISASSEMBLER
356 static const int kCodeTargetMask = (1 << (LAST_CODE_ENUM + 1)) - 1;
357 static const int kPositionMask = 1 << POSITION | 1 << STATEMENT_POSITION;
358 static const int kDataMask =
359 (1 << CODE_TARGET_WITH_ID) | kPositionMask | (1 << COMMENT);
376 Object* reconstructed_obj_ptr_;
381 Address reconstructed_adr_ptr_;
402 void Write(
const RelocInfo* rinfo);
416 static const int kMaxSize = 16;
419 inline uint32_t WriteVariableLengthPCJump(uint32_t pc_delta);
420 inline void WriteTaggedPC(uint32_t pc_delta,
int tag);
421 inline void WriteExtraTaggedPC(uint32_t pc_delta,
int extra_tag);
422 inline void WriteExtraTaggedIntData(
int data_delta,
int top_tag);
423 inline void WriteExtraTaggedConstPoolData(
int data);
424 inline void WriteExtraTaggedData(intptr_t data_delta,
int top_tag);
425 inline void WriteTaggedData(intptr_t data_delta,
int tag);
426 inline void WriteExtraTag(
int extra_tag,
int top_tag);
454 bool done()
const {
return done_; }
467 void Advance(
int bytes = 1) { pos_ -= bytes; }
472 void AdvanceReadPC();
473 void AdvanceReadId();
474 void AdvanceReadConstPoolData();
475 void AdvanceReadPosition();
476 void AdvanceReadData();
477 void AdvanceReadVariableLengthPCJump();
478 int GetLocatableTypeTag();
480 void ReadTaggedPosition();
484 bool SetMode(RelocInfo::Mode mode) {
485 return (mode_mask_ & (1 << mode)) ? (rinfo_.rmode_ = mode,
true) :
false;
504 class SCTableReference;
505 #ifdef ENABLE_DEBUGGER_SUPPORT
564 #ifdef ENABLE_DEBUGGER_SUPPORT
565 ExternalReference(
const Debug_Address& debug_address,
Isolate* isolate);
575 static ExternalReference isolate_address();
581 static ExternalReference incremental_marking_record_write_function(
583 static ExternalReference incremental_evacuation_record_write_function(
585 static ExternalReference store_buffer_overflow_function(
587 static ExternalReference flush_icache_function(
Isolate* isolate);
588 static ExternalReference perform_gc_function(
Isolate* isolate);
589 static ExternalReference fill_heap_number_with_random_function(
591 static ExternalReference random_uint32_function(
Isolate* isolate);
592 static ExternalReference transcendental_cache_array_address(
Isolate* isolate);
593 static ExternalReference delete_handle_scope_extensions(
Isolate* isolate);
595 static ExternalReference get_date_field_function(
Isolate* isolate);
596 static ExternalReference date_cache_stamp(
Isolate* isolate);
599 static ExternalReference new_deoptimizer_function(
Isolate* isolate);
600 static ExternalReference compute_output_frames_function(
Isolate* isolate);
603 static ExternalReference keyed_lookup_cache_keys(
Isolate* isolate);
604 static ExternalReference keyed_lookup_cache_field_offsets(
Isolate* isolate);
607 static ExternalReference roots_array_start(
Isolate* isolate);
610 static ExternalReference address_of_stack_limit(
Isolate* isolate);
613 static ExternalReference address_of_real_stack_limit(
Isolate* isolate);
616 static ExternalReference address_of_regexp_stack_limit(
Isolate* isolate);
619 static ExternalReference address_of_static_offsets_vector(
Isolate* isolate);
620 static ExternalReference address_of_regexp_stack_memory_address(
622 static ExternalReference address_of_regexp_stack_memory_size(
626 static ExternalReference new_space_start(
Isolate* isolate);
627 static ExternalReference new_space_mask(
Isolate* isolate);
628 static ExternalReference heap_always_allocate_scope_depth(
Isolate* isolate);
629 static ExternalReference new_space_mark_bits(
Isolate* isolate);
632 static ExternalReference store_buffer_top(
Isolate* isolate);
635 static ExternalReference new_space_allocation_top_address(
Isolate* isolate);
636 static ExternalReference new_space_allocation_limit_address(
Isolate* isolate);
638 static ExternalReference double_fp_operation(
Token::Value operation,
640 static ExternalReference compare_doubles(
Isolate* isolate);
641 static ExternalReference power_double_double_function(
Isolate* isolate);
642 static ExternalReference power_double_int_function(
Isolate* isolate);
644 static ExternalReference handle_scope_next_address();
645 static ExternalReference handle_scope_limit_address();
646 static ExternalReference handle_scope_level_address();
648 static ExternalReference scheduled_exception_address(
Isolate* isolate);
649 static ExternalReference address_of_pending_message_obj(
Isolate* isolate);
650 static ExternalReference address_of_has_pending_message(
Isolate* isolate);
651 static ExternalReference address_of_pending_message_script(
Isolate* isolate);
654 static ExternalReference address_of_min_int();
655 static ExternalReference address_of_one_half();
656 static ExternalReference address_of_minus_zero();
657 static ExternalReference address_of_zero();
658 static ExternalReference address_of_uint8_max_value();
659 static ExternalReference address_of_negative_infinity();
660 static ExternalReference address_of_canonical_non_hole_nan();
661 static ExternalReference address_of_the_hole_nan();
663 static ExternalReference math_sin_double_function(
Isolate* isolate);
664 static ExternalReference math_cos_double_function(
Isolate* isolate);
665 static ExternalReference math_tan_double_function(
Isolate* isolate);
666 static ExternalReference math_log_double_function(
Isolate* isolate);
668 static ExternalReference page_flags(
Page* page);
672 #ifdef ENABLE_DEBUGGER_SUPPORT
674 static ExternalReference debug_break(
Isolate* isolate);
677 static ExternalReference debug_step_in_fp_address(
Isolate* isolate);
680 #ifndef V8_INTERPRETED_REGEXP
684 static ExternalReference re_case_insensitive_compare_uc16(
Isolate* isolate);
687 static ExternalReference re_check_stack_guard_state(
Isolate* isolate);
690 static ExternalReference re_grow_stack(
Isolate* isolate);
693 static ExternalReference re_word_character_map();
700 ExternalReferenceRedirector* redirector) {
702 ASSERT(isolate->external_reference_redirector() ==
NULL);
703 isolate->set_external_reference_redirector(
704 reinterpret_cast<ExternalReferenceRedirectorPointer*>(redirector));
708 explicit ExternalReference(
void* address)
709 : address_(address) {}
711 static void* Redirect(
Isolate* isolate,
713 Type type = ExternalReference::BUILTIN_CALL) {
714 ExternalReferenceRedirector* redirector =
715 reinterpret_cast<ExternalReferenceRedirector*
>(
716 isolate->external_reference_redirector());
717 if (redirector ==
NULL)
return address;
718 void* answer = (*redirector)(address, type);
722 static void* Redirect(Isolate* isolate,
724 Type type = ExternalReference::BUILTIN_CALL) {
725 ExternalReferenceRedirector* redirector =
726 reinterpret_cast<ExternalReferenceRedirector*
>(
727 isolate->external_reference_redirector());
728 void* address =
reinterpret_cast<void*
>(address_arg);
729 void* answer = (redirector ==
NULL) ?
731 (*redirector)(address, type);
759 : assembler_(assembler) {
760 #ifdef ENABLE_GDB_JIT_INTERFACE
761 gdbjit_lineinfo_ =
NULL;
765 #ifdef ENABLE_GDB_JIT_INTERFACE
766 ~PositionsRecorder() {
767 delete gdbjit_lineinfo_;
770 void StartGDBJITLineInfoRecording() {
772 gdbjit_lineinfo_ =
new GDBJITLineInfo();
776 GDBJITLineInfo* DetachGDBJITLineInfo() {
777 GDBJITLineInfo* lineinfo = gdbjit_lineinfo_;
778 gdbjit_lineinfo_ =
NULL;
784 void RecordPosition(
int pos);
787 void RecordStatementPosition(
int pos);
790 bool WriteRecordedPositions();
795 return state_.current_statement_position;
801 #ifdef ENABLE_GDB_JIT_INTERFACE
802 GDBJITLineInfo* gdbjit_lineinfo_;
805 friend class PreservePositionScope;
814 : positions_recorder_(positions_recorder),
815 saved_state_(positions_recorder->state_) {}
818 positions_recorder_->state_ = saved_state_;
822 PositionsRecorder* positions_recorder_;
833 return -(1 << (n-1)) <= x && x < (1 << (n-1));
842 return (x & -(1 << n)) == 0;
859 unsigned int num_bits_set;
860 for (num_bits_set = 0; x; x >>= 1) {
861 num_bits_set += x & 1;
881 virtual void BeforeCall(
int call_size)
const = 0;
896 #endif // V8_ASSEMBLER_H_
RelocIterator(Code *code, int mode_mask=-1)
static bool IsDebugBreakSlot(Mode mode)
Isolate * isolate() const
int near_link_pos() const
static bool IsExternalReference(Mode mode)
RelocInfo(byte *pc, Mode rmode, intptr_t data, Code *host)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 instructions(ARM only)") DEFINE_bool(enable_vfp2
bool is_intn(int x, int n)
virtual void BeforeCall(int call_size) const =0
int written_statement_position
virtual ~NullCallWrapper()
static void set_redirector(Isolate *isolate, ExternalReferenceRedirector *redirector)
PositionsRecorder(Assembler *assembler)
void * ExternalReferenceRedirector(void *original, Type type)
int current_statement_position() const
#define ASSERT(condition)
v8::Handle< v8::Value > Print(const v8::Arguments &args)
static bool IsComment(Mode mode)
static void QuietNaN(HeapObject *nan)
void Reposition(byte *pos, byte *pc)
PreservePositionScope(PositionsRecorder *positions_recorder)
static bool IsConstPool(Mode mode)
static const int kApplyMask
double power_double_double(double x, double y)
virtual void AfterCall() const
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
static bool IsJSReturn(Mode mode)
static const int kMaxSmallPCDelta
double power_double_int(double x, int y)
static bool IsStatementPosition(Mode mode)
static bool IsEmbeddedObject(Mode mode)
INLINE(bool is_near_linked() const)
AssemblerBase(Isolate *isolate)
static bool IsPosition(Mode mode)
INLINE(static HeapObject *EnsureDoubleAligned(Heap *heap, HeapObject *object, int size))
static bool IsGCRelocMode(Mode mode)
static int ModeMask(Mode mode)
static bool IsCodeTarget(Mode mode)
int current_statement_position
static bool IsInternalReference(Mode mode)
RelocInfoWriter(byte *pos, byte *pc)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL
static bool IsConstructCall(Mode mode)
virtual void AfterCall() const =0
INLINE(bool is_unused() const)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
virtual void BeforeCall(int call_size) const
int NumberOfBitsSet(uint32_t x)
INLINE(bool is_linked() const)
bool EvalComparison(Token::Value op, double op1, double op2)
bool is_uintn(int x, int n)
int current_position() const
INLINE(bool is_bound() const)
static const char *const kFillerCommentString