Cleanup: Unify CodeGenerator class across platforms

R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/134643026

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19072 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6fa34198
......@@ -34,50 +34,9 @@
namespace v8 {
namespace internal {
// Forward declarations
class CompilationInfo;
enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
// -------------------------------------------------------------------------
// CodeGenerator
class CodeGenerator: public AstVisitor {
public:
explicit CodeGenerator(Zone* zone) {
InitializeAstVisitor(zone);
}
static bool MakeCode(CompilationInfo* info);
// Printing of AST, etc. as requested by flags.
static void MakeCodePrologue(CompilationInfo* info, const char* kind);
// Allocate and install the code.
static Handle<Code> MakeCodeEpilogue(MacroAssembler* masm,
Code::Flags flags,
CompilationInfo* info);
// Print the code after compiling it.
static void PrintCode(Handle<Code> code, CompilationInfo* info);
static bool ShouldGenerateLog(Isolate* isolate, Expression* type);
static void SetFunctionInfo(Handle<JSFunction> fun,
FunctionLiteral* lit,
bool is_toplevel,
Handle<Script> script);
static bool RecordPositions(MacroAssembler* masm,
int pos,
bool right_here = false);
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
private:
DISALLOW_COPY_AND_ASSIGN(CodeGenerator);
};
class StringCharLoadGenerator : public AllStatic {
public:
......
......@@ -3828,7 +3828,6 @@ void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) {
Label done, not_found;
// tmp now holds finger offset as a smi.
__ ldr(r2, FieldMemOperand(cache, JSFunctionResultCache::kFingerOffset));
// r2 now holds finger offset as a smi.
__ add(r3, cache, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
......
......@@ -83,6 +83,34 @@ enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
namespace v8 {
namespace internal {
class CompilationInfo;
class CodeGenerator {
public:
// Printing of AST, etc. as requested by flags.
static void MakeCodePrologue(CompilationInfo* info, const char* kind);
// Allocate and install the code.
static Handle<Code> MakeCodeEpilogue(MacroAssembler* masm,
Code::Flags flags,
CompilationInfo* info);
// Print the code after compiling it.
static void PrintCode(Handle<Code> code, CompilationInfo* info);
static bool ShouldGenerateLog(Isolate* isolate, Expression* type);
static bool RecordPositions(MacroAssembler* masm,
int pos,
bool right_here = false);
private:
DISALLOW_COPY_AND_ASSIGN(CodeGenerator);
};
// Results of the library implementation of transcendental functions may differ
// from the one we use in our generated code. Therefore we use the same
// generated code both in runtime and compiled code.
......
......@@ -34,43 +34,6 @@
namespace v8 {
namespace internal {
// Forward declarations
class CompilationInfo;
// -------------------------------------------------------------------------
// CodeGenerator
class CodeGenerator {
public:
// Printing of AST, etc. as requested by flags.
static void MakeCodePrologue(CompilationInfo* info, const char* kind);
// Allocate and install the code.
static Handle<Code> MakeCodeEpilogue(MacroAssembler* masm,
Code::Flags flags,
CompilationInfo* info);
// Print the code after compiling it.
static void PrintCode(Handle<Code> code, CompilationInfo* info);
static bool ShouldGenerateLog(Isolate* isolate, Expression* type);
static bool RecordPositions(MacroAssembler* masm,
int pos,
bool right_here = false);
static Operand FixedArrayElementOperand(Register array,
Register index_as_smi,
int additional_offset = 0) {
int offset = FixedArray::kHeaderSize + additional_offset * kPointerSize;
return FieldOperand(array, index_as_smi, times_half_pointer_size, offset);
}
private:
DISALLOW_COPY_AND_ASSIGN(CodeGenerator);
};
class StringCharLoadGenerator : public AllStatic {
public:
......
......@@ -3793,13 +3793,13 @@ void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) {
FieldOperand(cache, FixedArray::OffsetOfElementAt(cache_id)));
Label done, not_found;
// tmp now holds finger offset as a smi.
STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1);
__ mov(tmp, FieldOperand(cache, JSFunctionResultCache::kFingerOffset));
__ cmp(key, CodeGenerator::FixedArrayElementOperand(cache, tmp));
// tmp now holds finger offset as a smi.
__ cmp(key, FixedArrayElementOperand(cache, tmp));
__ j(not_equal, &not_found);
__ mov(eax, CodeGenerator::FixedArrayElementOperand(cache, tmp, 1));
__ mov(eax, FixedArrayElementOperand(cache, tmp, 1));
__ jmp(&done);
__ bind(&not_found);
......
......@@ -738,7 +738,7 @@ static void KeyedStoreGenerateGenericHelper(
// We have to go to the runtime if the current value is the hole because
// there may be a callback on the element
Label holecheck_passed1;
__ cmp(CodeGenerator::FixedArrayElementOperand(ebx, ecx),
__ cmp(FixedArrayElementOperand(ebx, ecx),
masm->isolate()->factory()->the_hole_value());
__ j(not_equal, &holecheck_passed1);
__ JumpIfDictionaryInPrototypeChain(edx, ebx, edi, slow);
......@@ -755,7 +755,7 @@ static void KeyedStoreGenerateGenericHelper(
Immediate(Smi::FromInt(1)));
}
// It's irrelevant whether array is smi-only or not when writing a smi.
__ mov(CodeGenerator::FixedArrayElementOperand(ebx, ecx), eax);
__ mov(FixedArrayElementOperand(ebx, ecx), eax);
__ ret(0);
__ bind(&non_smi_value);
......@@ -770,7 +770,7 @@ static void KeyedStoreGenerateGenericHelper(
__ add(FieldOperand(edx, JSArray::kLengthOffset),
Immediate(Smi::FromInt(1)));
}
__ mov(CodeGenerator::FixedArrayElementOperand(ebx, ecx), eax);
__ mov(FixedArrayElementOperand(ebx, ecx), eax);
// Update write barrier for the elements array address.
__ mov(edx, eax); // Preserve the value which is returned.
__ RecordWriteArray(
......
......@@ -1082,6 +1082,14 @@ inline Operand FieldOperand(Register object,
}
inline Operand FixedArrayElementOperand(Register array,
Register index_as_smi,
int additional_offset = 0) {
int offset = FixedArray::kHeaderSize + additional_offset * kPointerSize;
return FieldOperand(array, index_as_smi, times_half_pointer_size, offset);
}
inline Operand ContextOperand(Register context, int index) {
return Operand(context, Context::SlotOffset(index));
}
......
......@@ -36,50 +36,9 @@
namespace v8 {
namespace internal {
// Forward declarations
class CompilationInfo;
enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
// -------------------------------------------------------------------------
// CodeGenerator
class CodeGenerator: public AstVisitor {
public:
explicit CodeGenerator(Zone* zone) {
InitializeAstVisitor(zone);
}
static bool MakeCode(CompilationInfo* info);
// Printing of AST, etc. as requested by flags.
static void MakeCodePrologue(CompilationInfo* info, const char* kind);
// Allocate and install the code.
static Handle<Code> MakeCodeEpilogue(MacroAssembler* masm,
Code::Flags flags,
CompilationInfo* info);
// Print the code after compiling it.
static void PrintCode(Handle<Code> code, CompilationInfo* info);
static bool ShouldGenerateLog(Isolate* isolate, Expression* type);
static void SetFunctionInfo(Handle<JSFunction> fun,
FunctionLiteral* lit,
bool is_toplevel,
Handle<Script> script);
static bool RecordPositions(MacroAssembler* masm,
int pos,
bool right_here = false);
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
private:
DISALLOW_COPY_AND_ASSIGN(CodeGenerator);
};
class StringCharLoadGenerator : public AllStatic {
public:
......
......@@ -34,45 +34,9 @@
namespace v8 {
namespace internal {
// Forward declarations
class CompilationInfo;
enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
// -------------------------------------------------------------------------
// CodeGenerator
class CodeGenerator: public AstVisitor {
public:
explicit CodeGenerator(Zone* zone) {
InitializeAstVisitor(zone);
}
static bool MakeCode(CompilationInfo* info);
// Printing of AST, etc. as requested by flags.
static void MakeCodePrologue(CompilationInfo* info, const char* kind);
// Allocate and install the code.
static Handle<Code> MakeCodeEpilogue(MacroAssembler* masm,
Code::Flags flags,
CompilationInfo* info);
// Print the code after compiling it.
static void PrintCode(Handle<Code> code, CompilationInfo* info);
static bool ShouldGenerateLog(Isolate* isolate, Expression* type);
static bool RecordPositions(MacroAssembler* masm,
int pos,
bool right_here = false);
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
private:
DISALLOW_COPY_AND_ASSIGN(CodeGenerator);
};
class StringCharLoadGenerator : public AllStatic {
public:
......
......@@ -3765,9 +3765,9 @@ void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) {
FieldOperand(cache, FixedArray::OffsetOfElementAt(cache_id)));
Label done, not_found;
// tmp now holds finger offset as a smi.
STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1);
__ movp(tmp, FieldOperand(cache, JSFunctionResultCache::kFingerOffset));
// tmp now holds finger offset as a smi.
SmiIndex index =
__ SmiToIndex(kScratchRegister, tmp, kPointerSizeLog2);
__ cmpq(key, FieldOperand(cache,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment