2012-01-09 16:37:47 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
2010-12-07 11:31:57 +00:00
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following
|
|
|
|
// disclaimer in the documentation and/or other materials provided
|
|
|
|
// with the distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived
|
|
|
|
// from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
#ifndef V8_IA32_LITHIUM_CODEGEN_IA32_H_
|
|
|
|
#define V8_IA32_LITHIUM_CODEGEN_IA32_H_
|
|
|
|
|
|
|
|
#include "ia32/lithium-ia32.h"
|
|
|
|
|
|
|
|
#include "checks.h"
|
|
|
|
#include "deoptimizer.h"
|
|
|
|
#include "safepoint-table.h"
|
|
|
|
#include "scopes.h"
|
2011-01-17 11:25:36 +00:00
|
|
|
#include "ia32/lithium-gap-resolver-ia32.h"
|
2010-12-07 11:31:57 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
// Forward declarations.
|
|
|
|
class LDeferredCode;
|
2011-01-14 12:50:03 +00:00
|
|
|
class LGapNode;
|
2010-12-07 11:31:57 +00:00
|
|
|
class SafepointGenerator;
|
|
|
|
|
|
|
|
class LCodeGen BASE_EMBEDDED {
|
|
|
|
public:
|
|
|
|
LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info)
|
|
|
|
: chunk_(chunk),
|
|
|
|
masm_(assembler),
|
|
|
|
info_(info),
|
|
|
|
current_block_(-1),
|
|
|
|
current_instruction_(-1),
|
|
|
|
instructions_(chunk->instructions()),
|
|
|
|
deoptimizations_(4),
|
|
|
|
deoptimization_literals_(8),
|
|
|
|
inlined_function_count_(0),
|
2011-03-07 11:52:36 +00:00
|
|
|
scope_(info->scope()),
|
2010-12-07 11:31:57 +00:00
|
|
|
status_(UNUSED),
|
|
|
|
deferred_(8),
|
2011-01-17 11:25:36 +00:00
|
|
|
osr_pc_offset_(-1),
|
2011-11-16 08:44:30 +00:00
|
|
|
last_lazy_deopt_pc_(0),
|
2011-04-07 13:32:45 +00:00
|
|
|
resolver_(this),
|
|
|
|
expected_safepoint_kind_(Safepoint::kSimple) {
|
2010-12-07 11:31:57 +00:00
|
|
|
PopulateDeoptimizationLiteralsWithInlinedFunctions();
|
|
|
|
}
|
|
|
|
|
2011-01-17 11:25:36 +00:00
|
|
|
// Simple accessors.
|
|
|
|
MacroAssembler* masm() const { return masm_; }
|
2011-03-07 11:52:36 +00:00
|
|
|
CompilationInfo* info() const { return info_; }
|
2011-03-18 20:35:07 +00:00
|
|
|
Isolate* isolate() const { return info_->isolate(); }
|
|
|
|
Factory* factory() const { return isolate()->factory(); }
|
|
|
|
Heap* heap() const { return isolate()->heap(); }
|
2011-01-17 11:25:36 +00:00
|
|
|
|
|
|
|
// Support for converting LOperands to assembler types.
|
|
|
|
Operand ToOperand(LOperand* op) const;
|
|
|
|
Register ToRegister(LOperand* op) const;
|
|
|
|
XMMRegister ToDoubleRegister(LOperand* op) const;
|
2011-12-23 10:39:01 +00:00
|
|
|
|
|
|
|
bool IsInteger32(LConstantOperand* op) const;
|
|
|
|
Immediate ToInteger32Immediate(LOperand* op) const {
|
|
|
|
return Immediate(ToInteger32(LConstantOperand::cast(op)));
|
|
|
|
}
|
|
|
|
|
|
|
|
Handle<Object> ToHandle(LConstantOperand* op) const;
|
2011-01-17 11:25:36 +00:00
|
|
|
|
|
|
|
// The operand denoting the second word (the one with a higher address) of
|
|
|
|
// a double stack slot.
|
|
|
|
Operand HighOperand(LOperand* op);
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// Try to generate code for the entire chunk, but it may fail if the
|
|
|
|
// chunk contains constructs we cannot handle. Returns true if the
|
|
|
|
// code generation attempt succeeded.
|
|
|
|
bool GenerateCode();
|
|
|
|
|
|
|
|
// Finish the code by setting stack height, safepoint, and bailout
|
|
|
|
// information on it.
|
|
|
|
void FinishCode(Handle<Code> code);
|
|
|
|
|
|
|
|
// Deferred code support.
|
|
|
|
void DoDeferredNumberTagD(LNumberTagD* instr);
|
|
|
|
void DoDeferredNumberTagI(LNumberTagI* instr);
|
|
|
|
void DoDeferredTaggedToI(LTaggedToI* instr);
|
|
|
|
void DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr);
|
2011-06-27 12:12:27 +00:00
|
|
|
void DoDeferredStackCheck(LStackCheck* instr);
|
2012-03-06 11:31:51 +00:00
|
|
|
void DoDeferredRandom(LRandom* instr);
|
2011-01-19 20:05:22 +00:00
|
|
|
void DoDeferredStringCharCodeAt(LStringCharCodeAt* instr);
|
2011-03-14 15:36:00 +00:00
|
|
|
void DoDeferredStringCharFromCode(LStringCharFromCode* instr);
|
2012-02-28 09:05:55 +00:00
|
|
|
void DoDeferredAllocateObject(LAllocateObject* instr);
|
2011-11-16 08:44:30 +00:00
|
|
|
void DoDeferredInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr,
|
|
|
|
Label* map_check);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2012-01-09 16:37:47 +00:00
|
|
|
void DoCheckMapCommon(Register reg, Handle<Map> map,
|
|
|
|
CompareMapMode mode, LEnvironment* env);
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// Parallel move support.
|
|
|
|
void DoParallelMove(LParallelMove* move);
|
2011-04-27 11:41:42 +00:00
|
|
|
void DoGap(LGap* instr);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2011-01-11 15:51:08 +00:00
|
|
|
// Emit frame translation commands for an environment.
|
|
|
|
void WriteTranslation(LEnvironment* environment, Translation* translation);
|
|
|
|
|
2011-02-22 12:28:33 +00:00
|
|
|
void EnsureRelocSpaceForDeoptimization();
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// Declare methods that deal with the individual node types.
|
|
|
|
#define DECLARE_DO(type) void Do##type(L##type* node);
|
|
|
|
LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
|
|
|
|
#undef DECLARE_DO
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum Status {
|
|
|
|
UNUSED,
|
|
|
|
GENERATING,
|
|
|
|
DONE,
|
|
|
|
ABORTED
|
|
|
|
};
|
|
|
|
|
|
|
|
bool is_unused() const { return status_ == UNUSED; }
|
|
|
|
bool is_generating() const { return status_ == GENERATING; }
|
|
|
|
bool is_done() const { return status_ == DONE; }
|
|
|
|
bool is_aborted() const { return status_ == ABORTED; }
|
|
|
|
|
2011-10-24 07:47:22 +00:00
|
|
|
StrictModeFlag strict_mode_flag() const {
|
2011-11-24 15:17:04 +00:00
|
|
|
return info()->is_classic_mode() ? kNonStrictMode : kStrictMode;
|
2011-02-14 23:41:47 +00:00
|
|
|
}
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
LChunk* chunk() const { return chunk_; }
|
|
|
|
Scope* scope() const { return scope_; }
|
|
|
|
HGraph* graph() const { return chunk_->graph(); }
|
|
|
|
|
|
|
|
int GetNextEmittedBlock(int block);
|
|
|
|
|
|
|
|
void EmitClassOfTest(Label* if_true,
|
|
|
|
Label* if_false,
|
|
|
|
Handle<String> class_name,
|
|
|
|
Register input,
|
|
|
|
Register temporary,
|
|
|
|
Register temporary2);
|
|
|
|
|
2011-04-15 07:58:22 +00:00
|
|
|
int GetStackSlotCount() const { return chunk()->spill_slot_count(); }
|
|
|
|
int GetParameterCount() const { return scope()->num_parameters(); }
|
2010-12-07 11:31:57 +00:00
|
|
|
|
|
|
|
void Abort(const char* format, ...);
|
|
|
|
void Comment(const char* format, ...);
|
|
|
|
|
|
|
|
void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code); }
|
|
|
|
|
|
|
|
// Code generation passes. Returns true if code generation should
|
|
|
|
// continue.
|
|
|
|
bool GeneratePrologue();
|
|
|
|
bool GenerateBody();
|
|
|
|
bool GenerateDeferredCode();
|
2011-02-22 12:28:33 +00:00
|
|
|
// Pad the reloc info to ensure that we have enough space to patch during
|
|
|
|
// deoptimization.
|
|
|
|
bool GenerateRelocPadding();
|
2010-12-07 11:31:57 +00:00
|
|
|
bool GenerateSafepointTable();
|
|
|
|
|
2011-04-07 13:32:45 +00:00
|
|
|
enum SafepointMode {
|
|
|
|
RECORD_SIMPLE_SAFEPOINT,
|
|
|
|
RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS
|
|
|
|
};
|
|
|
|
|
|
|
|
void CallCode(Handle<Code> code,
|
|
|
|
RelocInfo::Mode mode,
|
2011-07-04 14:13:08 +00:00
|
|
|
LInstruction* instr);
|
2011-04-07 13:32:45 +00:00
|
|
|
|
|
|
|
void CallCodeGeneric(Handle<Code> code,
|
|
|
|
RelocInfo::Mode mode,
|
|
|
|
LInstruction* instr,
|
|
|
|
SafepointMode safepoint_mode);
|
|
|
|
|
|
|
|
void CallRuntime(const Runtime::Function* fun,
|
|
|
|
int argc,
|
2011-07-04 14:13:08 +00:00
|
|
|
LInstruction* instr);
|
2011-04-07 13:32:45 +00:00
|
|
|
|
|
|
|
void CallRuntime(Runtime::FunctionId id,
|
|
|
|
int argc,
|
2011-07-04 14:13:08 +00:00
|
|
|
LInstruction* instr) {
|
2011-03-18 20:35:07 +00:00
|
|
|
const Runtime::Function* function = Runtime::FunctionForId(id);
|
2011-07-04 14:13:08 +00:00
|
|
|
CallRuntime(function, argc, instr);
|
2010-12-07 11:31:57 +00:00
|
|
|
}
|
|
|
|
|
2011-04-07 13:32:45 +00:00
|
|
|
void CallRuntimeFromDeferred(Runtime::FunctionId id,
|
|
|
|
int argc,
|
2011-07-04 14:13:08 +00:00
|
|
|
LInstruction* instr,
|
|
|
|
LOperand* context);
|
2011-04-07 13:32:45 +00:00
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// Generate a direct call to a known function. Expects the function
|
|
|
|
// to be in edi.
|
|
|
|
void CallKnownFunction(Handle<JSFunction> function,
|
|
|
|
int arity,
|
2011-05-24 14:01:36 +00:00
|
|
|
LInstruction* instr,
|
|
|
|
CallKind call_kind);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2011-11-16 08:44:30 +00:00
|
|
|
void RecordSafepointWithLazyDeopt(LInstruction* instr,
|
|
|
|
SafepointMode safepoint_mode);
|
2011-04-07 13:32:45 +00:00
|
|
|
|
2011-11-16 08:44:30 +00:00
|
|
|
void RegisterEnvironmentForDeoptimization(LEnvironment* environment,
|
|
|
|
Safepoint::DeoptMode mode);
|
2010-12-07 11:31:57 +00:00
|
|
|
void DeoptimizeIf(Condition cc, LEnvironment* environment);
|
|
|
|
|
|
|
|
void AddToTranslation(Translation* translation,
|
|
|
|
LOperand* op,
|
|
|
|
bool is_tagged);
|
|
|
|
void PopulateDeoptimizationData(Handle<Code> code);
|
|
|
|
int DefineDeoptimizationLiteral(Handle<Object> literal);
|
|
|
|
|
|
|
|
void PopulateDeoptimizationLiteralsWithInlinedFunctions();
|
|
|
|
|
|
|
|
Register ToRegister(int index) const;
|
|
|
|
XMMRegister ToDoubleRegister(int index) const;
|
|
|
|
int ToInteger32(LConstantOperand* op) const;
|
2011-12-23 10:39:01 +00:00
|
|
|
|
2011-10-20 10:26:45 +00:00
|
|
|
double ToDouble(LConstantOperand* op) const;
|
2011-08-16 13:32:27 +00:00
|
|
|
Operand BuildFastArrayOperand(LOperand* elements_pointer,
|
2011-07-19 13:04:00 +00:00
|
|
|
LOperand* key,
|
2011-09-09 09:35:57 +00:00
|
|
|
ElementsKind elements_kind,
|
2011-07-19 13:04:00 +00:00
|
|
|
uint32_t offset);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
|
|
|
// Specific math operations - used from DoUnaryMathOperation.
|
2011-01-20 08:08:36 +00:00
|
|
|
void EmitIntegerMathAbs(LUnaryMathOperation* instr);
|
2010-12-07 11:31:57 +00:00
|
|
|
void DoMathAbs(LUnaryMathOperation* instr);
|
|
|
|
void DoMathFloor(LUnaryMathOperation* instr);
|
|
|
|
void DoMathRound(LUnaryMathOperation* instr);
|
|
|
|
void DoMathSqrt(LUnaryMathOperation* instr);
|
2010-12-14 13:21:29 +00:00
|
|
|
void DoMathLog(LUnaryMathOperation* instr);
|
2011-11-25 13:15:31 +00:00
|
|
|
void DoMathTan(LUnaryMathOperation* instr);
|
2010-12-20 13:52:14 +00:00
|
|
|
void DoMathCos(LUnaryMathOperation* instr);
|
|
|
|
void DoMathSin(LUnaryMathOperation* instr);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
|
|
|
// Support for recording safepoint and position information.
|
2011-01-26 20:48:48 +00:00
|
|
|
void RecordSafepoint(LPointerMap* pointers,
|
|
|
|
Safepoint::Kind kind,
|
|
|
|
int arguments,
|
2011-11-16 08:44:30 +00:00
|
|
|
Safepoint::DeoptMode mode);
|
|
|
|
void RecordSafepoint(LPointerMap* pointers, Safepoint::DeoptMode mode);
|
|
|
|
void RecordSafepoint(Safepoint::DeoptMode mode);
|
2010-12-07 11:31:57 +00:00
|
|
|
void RecordSafepointWithRegisters(LPointerMap* pointers,
|
|
|
|
int arguments,
|
2011-11-16 08:44:30 +00:00
|
|
|
Safepoint::DeoptMode mode);
|
2010-12-07 11:31:57 +00:00
|
|
|
void RecordPosition(int position);
|
|
|
|
|
|
|
|
static Condition TokenToCondition(Token::Value op, bool is_unsigned);
|
2011-06-27 12:12:27 +00:00
|
|
|
void EmitGoto(int block);
|
2010-12-07 11:31:57 +00:00
|
|
|
void EmitBranch(int left_block, int right_block, Condition cc);
|
2011-06-09 12:27:28 +00:00
|
|
|
void EmitNumberUntagD(Register input,
|
2012-01-11 15:43:33 +00:00
|
|
|
Register temp,
|
2011-06-09 12:27:28 +00:00
|
|
|
XMMRegister result,
|
|
|
|
bool deoptimize_on_undefined,
|
2012-01-11 15:43:33 +00:00
|
|
|
bool deoptimize_on_minus_zero,
|
2011-06-09 12:27:28 +00:00
|
|
|
LEnvironment* env);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
|
|
|
// Emits optimized code for typeof x == "y". Modifies input register.
|
|
|
|
// Returns the condition on which a final split to
|
|
|
|
// true and false label should be made, to optimize fallthrough.
|
2011-10-14 07:45:18 +00:00
|
|
|
Condition EmitTypeofIs(Label* true_label,
|
|
|
|
Label* false_label,
|
|
|
|
Register input,
|
|
|
|
Handle<String> type_name);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2010-12-15 12:32:19 +00:00
|
|
|
// Emits optimized code for %_IsObject(x). Preserves input register.
|
|
|
|
// Returns the condition on which a final split to
|
|
|
|
// true and false label should be made, to optimize fallthrough.
|
|
|
|
Condition EmitIsObject(Register input,
|
|
|
|
Register temp1,
|
|
|
|
Label* is_not_object,
|
|
|
|
Label* is_object);
|
|
|
|
|
2011-11-17 13:57:55 +00:00
|
|
|
// Emits optimized code for %_IsString(x). Preserves input register.
|
|
|
|
// Returns the condition on which a final split to
|
|
|
|
// true and false label should be made, to optimize fallthrough.
|
|
|
|
Condition EmitIsString(Register input,
|
|
|
|
Register temp1,
|
|
|
|
Label* is_not_string);
|
|
|
|
|
2011-02-08 10:08:47 +00:00
|
|
|
// Emits optimized code for %_IsConstructCall().
|
|
|
|
// Caller should branch on equal condition.
|
|
|
|
void EmitIsConstructCall(Register temp);
|
|
|
|
|
2011-05-05 09:22:09 +00:00
|
|
|
void EmitLoadFieldOrConstantFunction(Register result,
|
|
|
|
Register object,
|
|
|
|
Handle<Map> type,
|
|
|
|
Handle<String> name);
|
2011-11-24 13:42:52 +00:00
|
|
|
|
|
|
|
// Emits optimized code to deep-copy the contents of statically known
|
|
|
|
// object graphs (e.g. object literal boilerplate).
|
|
|
|
void EmitDeepCopy(Handle<JSObject> object,
|
|
|
|
Register result,
|
|
|
|
Register source,
|
|
|
|
int* offset);
|
|
|
|
|
2011-11-16 08:44:30 +00:00
|
|
|
void EnsureSpaceForLazyDeopt();
|
2011-02-08 10:08:47 +00:00
|
|
|
|
2011-12-06 12:11:08 +00:00
|
|
|
// Emits code for pushing either a tagged constant, a (non-double)
|
|
|
|
// register, or a stack slot operand.
|
|
|
|
void EmitPushTaggedOperand(LOperand* operand);
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
LChunk* const chunk_;
|
|
|
|
MacroAssembler* const masm_;
|
|
|
|
CompilationInfo* const info_;
|
|
|
|
|
|
|
|
int current_block_;
|
|
|
|
int current_instruction_;
|
|
|
|
const ZoneList<LInstruction*>* instructions_;
|
|
|
|
ZoneList<LEnvironment*> deoptimizations_;
|
|
|
|
ZoneList<Handle<Object> > deoptimization_literals_;
|
|
|
|
int inlined_function_count_;
|
|
|
|
Scope* const scope_;
|
|
|
|
Status status_;
|
|
|
|
TranslationBuffer translations_;
|
|
|
|
ZoneList<LDeferredCode*> deferred_;
|
|
|
|
int osr_pc_offset_;
|
2011-11-16 08:44:30 +00:00
|
|
|
int last_lazy_deopt_pc_;
|
2011-02-22 12:28:33 +00:00
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// Builder that keeps track of safepoints in the code. The table
|
|
|
|
// itself is emitted at the end of the generated code.
|
|
|
|
SafepointTableBuilder safepoints_;
|
|
|
|
|
2011-01-11 13:50:12 +00:00
|
|
|
// Compiler from a set of parallel moves to a sequential list of moves.
|
|
|
|
LGapResolver resolver_;
|
|
|
|
|
2011-04-07 13:32:45 +00:00
|
|
|
Safepoint::Kind expected_safepoint_kind_;
|
|
|
|
|
|
|
|
class PushSafepointRegistersScope BASE_EMBEDDED {
|
|
|
|
public:
|
|
|
|
explicit PushSafepointRegistersScope(LCodeGen* codegen)
|
|
|
|
: codegen_(codegen) {
|
|
|
|
ASSERT(codegen_->expected_safepoint_kind_ == Safepoint::kSimple);
|
|
|
|
codegen_->masm_->PushSafepointRegisters();
|
|
|
|
codegen_->expected_safepoint_kind_ = Safepoint::kWithRegisters;
|
|
|
|
}
|
|
|
|
|
|
|
|
~PushSafepointRegistersScope() {
|
|
|
|
ASSERT(codegen_->expected_safepoint_kind_ == Safepoint::kWithRegisters);
|
|
|
|
codegen_->masm_->PopSafepointRegisters();
|
|
|
|
codegen_->expected_safepoint_kind_ = Safepoint::kSimple;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
LCodeGen* codegen_;
|
|
|
|
};
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
friend class LDeferredCode;
|
|
|
|
friend class LEnvironment;
|
|
|
|
friend class SafepointGenerator;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(LCodeGen);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class LDeferredCode: public ZoneObject {
|
|
|
|
public:
|
|
|
|
explicit LDeferredCode(LCodeGen* codegen)
|
2011-09-26 09:32:10 +00:00
|
|
|
: codegen_(codegen),
|
|
|
|
external_exit_(NULL),
|
|
|
|
instruction_index_(codegen->current_instruction_) {
|
2010-12-07 11:31:57 +00:00
|
|
|
codegen->AddDeferredCode(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~LDeferredCode() { }
|
|
|
|
virtual void Generate() = 0;
|
2011-09-26 09:32:10 +00:00
|
|
|
virtual LInstruction* instr() = 0;
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2012-01-13 13:09:52 +00:00
|
|
|
void SetExit(Label* exit) { external_exit_ = exit; }
|
2010-12-07 11:31:57 +00:00
|
|
|
Label* entry() { return &entry_; }
|
|
|
|
Label* exit() { return external_exit_ != NULL ? external_exit_ : &exit_; }
|
2011-09-26 09:32:10 +00:00
|
|
|
int instruction_index() const { return instruction_index_; }
|
2010-12-07 11:31:57 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
LCodeGen* codegen() const { return codegen_; }
|
|
|
|
MacroAssembler* masm() const { return codegen_->masm(); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
LCodeGen* codegen_;
|
|
|
|
Label entry_;
|
|
|
|
Label exit_;
|
|
|
|
Label* external_exit_;
|
2011-09-26 09:32:10 +00:00
|
|
|
int instruction_index_;
|
2010-12-07 11:31:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} } // namespace v8::internal
|
|
|
|
|
|
|
|
#endif // V8_IA32_LITHIUM_CODEGEN_IA32_H_
|