56
56
deoptimizations_(4),
57
57
deoptimization_literals_(8),
58
58
inlined_function_count_(0),
59
scope_(chunk->graph()->info()->scope()),
59
scope_(info->scope()),
62
62
osr_pc_offset_(-1),
63
deoptimization_reloc_size(),
63
last_lazy_deopt_pc_(0),
65
65
expected_safepoint_kind_(Safepoint::kSimple) {
66
66
PopulateDeoptimizationLiteralsWithInlinedFunctions();
69
69
// Simple accessors.
70
70
MacroAssembler* masm() const { return masm_; }
71
CompilationInfo* info() const { return info_; }
72
Isolate* isolate() const { return info_->isolate(); }
73
Factory* factory() const { return isolate()->factory(); }
74
Heap* heap() const { return isolate()->heap(); }
72
76
// Support for converting LOperands to assembler types.
73
77
Operand ToOperand(LOperand* op) const;
93
97
void DoDeferredNumberTagI(LNumberTagI* instr);
94
98
void DoDeferredTaggedToI(LTaggedToI* instr);
95
99
void DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr);
96
void DoDeferredStackCheck(LGoto* instr);
100
void DoDeferredStackCheck(LStackCheck* instr);
97
101
void DoDeferredStringCharCodeAt(LStringCharCodeAt* instr);
98
void DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr,
102
void DoDeferredStringCharFromCode(LStringCharFromCode* instr);
103
void DoDeferredInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr,
101
106
// Parallel move support.
102
107
void DoParallelMove(LParallelMove* move);
108
void DoGap(LGap* instr);
104
110
// Emit frame translation commands for an environment.
105
111
void WriteTranslation(LEnvironment* environment, Translation* translation);
125
131
bool is_aborted() const { return status_ == ABORTED; }
127
133
int strict_mode_flag() const {
128
return info_->is_strict() ? kStrictMode : kNonStrictMode;
134
return info()->is_strict_mode() ? kStrictMode : kNonStrictMode;
131
137
LChunk* chunk() const { return chunk_; }
133
139
HGraph* graph() const { return chunk_->graph(); }
135
141
int GetNextEmittedBlock(int block);
136
LInstruction* GetNextInstruction();
138
143
void EmitClassOfTest(Label* if_true,
142
147
Register temporary,
143
148
Register temporary2);
145
int StackSlotCount() const { return chunk()->spill_slot_count(); }
146
int ParameterCount() const { return scope()->num_parameters(); }
150
int GetStackSlotCount() const { return chunk()->spill_slot_count(); }
151
int GetParameterCount() const { return scope()->num_parameters(); }
148
153
void Abort(const char* format, ...);
149
154
void Comment(const char* format, ...);
173
173
void CallCode(Handle<Code> code,
174
174
RelocInfo::Mode mode,
176
ContextMode context_mode);
175
LInstruction* instr);
178
177
void CallCodeGeneric(Handle<Code> code,
179
178
RelocInfo::Mode mode,
180
179
LInstruction* instr,
181
ContextMode context_mode,
182
180
SafepointMode safepoint_mode);
184
void CallRuntime(Runtime::Function* fun,
182
void CallRuntime(const Runtime::Function* fun,
187
ContextMode context_mode);
184
LInstruction* instr);
189
186
void CallRuntime(Runtime::FunctionId id,
192
ContextMode context_mode) {
193
Runtime::Function* function = Runtime::FunctionForId(id);
194
CallRuntime(function, argc, instr, context_mode);
188
LInstruction* instr) {
189
const Runtime::Function* function = Runtime::FunctionForId(id);
190
CallRuntime(function, argc, instr);
197
193
void CallRuntimeFromDeferred(Runtime::FunctionId id,
199
LInstruction* instr);
201
198
// Generate a direct call to a known function. Expects the function
203
200
void CallKnownFunction(Handle<JSFunction> function,
205
LInstruction* instr);
207
205
void LoadHeapObject(Register result, Handle<HeapObject> object);
209
void RegisterLazyDeoptimization(LInstruction* instr,
210
SafepointMode safepoint_mode);
207
void RecordSafepointWithLazyDeopt(LInstruction* instr,
208
SafepointMode safepoint_mode);
212
void RegisterEnvironmentForDeoptimization(LEnvironment* environment);
210
void RegisterEnvironmentForDeoptimization(LEnvironment* environment,
211
Safepoint::DeoptMode mode);
213
212
void DeoptimizeIf(Condition cc, LEnvironment* environment);
215
214
void AddToTranslation(Translation* translation,
223
222
Register ToRegister(int index) const;
224
223
XMMRegister ToDoubleRegister(int index) const;
225
224
int ToInteger32(LConstantOperand* op) const;
225
Operand BuildFastArrayOperand(LOperand* elements_pointer,
227
ElementsKind elements_kind,
227
230
// Specific math operations - used from DoUnaryMathOperation.
228
231
void EmitIntegerMathAbs(LUnaryMathOperation* instr);
239
242
void RecordSafepoint(LPointerMap* pointers,
240
243
Safepoint::Kind kind,
242
int deoptimization_index);
243
void RecordSafepoint(LPointerMap* pointers, int deoptimization_index);
244
void RecordSafepoint(int deoptimization_index);
245
Safepoint::DeoptMode mode);
246
void RecordSafepoint(LPointerMap* pointers, Safepoint::DeoptMode mode);
247
void RecordSafepoint(Safepoint::DeoptMode mode);
245
248
void RecordSafepointWithRegisters(LPointerMap* pointers,
247
int deoptimization_index);
250
Safepoint::DeoptMode mode);
248
251
void RecordPosition(int position);
250
253
static Condition TokenToCondition(Token::Value op, bool is_unsigned);
251
void EmitGoto(int block, LDeferredCode* deferred_stack_check = NULL);
254
void EmitGoto(int block);
252
255
void EmitBranch(int left_block, int right_block, Condition cc);
253
256
void EmitCmpI(LOperand* left, LOperand* right);
254
void EmitNumberUntagD(Register input, XMMRegister result, LEnvironment* env);
257
void EmitNumberUntagD(Register input,
259
bool deoptimize_on_undefined,
256
262
// Emits optimized code for typeof x == "y". Modifies input register.
257
263
// Returns the condition on which a final split to
272
277
// Caller should branch on equal condition.
273
278
void EmitIsConstructCall(Register temp);
280
void EmitLoadFieldOrConstantFunction(Register result,
283
Handle<String> name);
284
void EnsureSpaceForLazyDeopt();
276
286
LChunk* const chunk_;
277
287
MacroAssembler* const masm_;
288
298
TranslationBuffer translations_;
289
299
ZoneList<LDeferredCode*> deferred_;
290
300
int osr_pc_offset_;
292
struct DeoptimizationRelocSize {
297
DeoptimizationRelocSize deoptimization_reloc_size;
301
int last_lazy_deopt_pc_;
299
303
// Builder that keeps track of safepoints in the code. The table
300
304
// itself is emitted at the end of the generated code.