Commit 594a30ef authored by whesse@chromium.org's avatar whesse@chromium.org

Add x64 implementation test support for assembler and code generator.

Review URL: http://codereview.chromium.org/123014

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2141 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent cf07b314
...@@ -1113,6 +1113,9 @@ bool Genesis::InstallNatives() { ...@@ -1113,6 +1113,9 @@ bool Genesis::InstallNatives() {
} }
#ifdef V8_HOST_ARCH_64_BIT #ifdef V8_HOST_ARCH_64_BIT
// TODO(X64): Remove these tests when code generation works and is stable.
MacroAssembler::ConstructAndTestJSFunction();
CodeGenerator::TestCodeGenerator();
// TODO(X64): Reenable remaining initialization when code generation works. // TODO(X64): Reenable remaining initialization when code generation works.
return true; return true;
#endif // V8_HOST_ARCH_64_BIT #endif // V8_HOST_ARCH_64_BIT
......
...@@ -58,15 +58,34 @@ CodeGenerator::CodeGenerator(int buffer_size, ...@@ -58,15 +58,34 @@ CodeGenerator::CodeGenerator(int buffer_size,
in_spilled_code_(false) { in_spilled_code_(false) {
} }
#define __ ACCESS_MASM(masm) #define __ ACCESS_MASM(masm_)
void CodeGenerator::DeclareGlobals(Handle<FixedArray> a) { void CodeGenerator::DeclareGlobals(Handle<FixedArray> a) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void CodeGenerator::TestCodeGenerator() {
// Generate code.
const int initial_buffer_size = 4 * KB;
CodeGenerator cgen(initial_buffer_size, NULL, false);
CodeGeneratorScope scope(&cgen);
cgen.GenCode(NULL);
CodeDesc desc;
cgen.masm()->GetCode(&desc);
}
void CodeGenerator::GenCode(FunctionLiteral* a) { void CodeGenerator::GenCode(FunctionLiteral* a) {
masm_->int3(); // UNIMPLEMENTED if (a != NULL) {
__ int3(); // UNIMPLEMENTED
} else {
// GenCode Implementation under construction. Run by TestCodeGenerator
// with a == NULL.
__ movq(rax, Immediate(0x2a));
__ Ret();
}
} }
void CodeGenerator::GenerateFastCaseSwitchJumpTable(SwitchStatement* a, void CodeGenerator::GenerateFastCaseSwitchJumpTable(SwitchStatement* a,
...@@ -235,6 +254,14 @@ void CodeGenerator::VisitThisFunction(ThisFunction* a) { ...@@ -235,6 +254,14 @@ void CodeGenerator::VisitThisFunction(ThisFunction* a) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
#undef __
// End of CodeGenerator implementation.
// -----------------------------------------------------------------------------
// Implementation of stubs.
// Stub classes have public member named masm, not masm_.
#define __ ACCESS_MASM(masm)
void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) { void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) {
// Check that stack should contain frame pointer, code pointer, state and // Check that stack should contain frame pointer, code pointer, state and
......
...@@ -286,6 +286,15 @@ class CodeGenerator: public AstVisitor { ...@@ -286,6 +286,15 @@ class CodeGenerator: public AstVisitor {
Handle<Script> script, Handle<Script> script,
bool is_eval); bool is_eval);
// During implementation of CodeGenerator, this call creates a
// CodeGenerator instance, and calls GenCode on it with a null
// function literal. CodeGenerator will then construct and return
// a simple dummy function. Call this during bootstrapping before
// trying to compile any real functions, to get CodeGenerator up
// and running.
// TODO(X64): Remove once we can get through the bootstrapping process.
static void TestCodeGenerator();
#ifdef ENABLE_LOGGING_AND_PROFILING #ifdef ENABLE_LOGGING_AND_PROFILING
static bool ShouldGenerateLog(Expression* type); static bool ShouldGenerateLog(Expression* type);
#endif #endif
......
...@@ -59,6 +59,21 @@ void MacroAssembler::Check(Condition cc, const char* msg) { ...@@ -59,6 +59,21 @@ void MacroAssembler::Check(Condition cc, const char* msg) {
} }
void MacroAssembler::ConstructAndTestJSFunction() {
const int initial_buffer_size = 4 * KB;
char* buffer = new char[initial_buffer_size];
MacroAssembler masm(buffer, initial_buffer_size);
#define __ ACCESS_MASM((&masm))
// Construct a simple JSfunction here, using Assembler and MacroAssembler
// commands.
__ int3();
#undef __
CodeDesc desc;
masm.GetCode(&desc);
// TODO(X64): Create the function object and call it.
}
void MacroAssembler::Abort(const char* msg) { void MacroAssembler::Abort(const char* msg) {
// We want to pass the msg string like a smi to avoid GC // We want to pass the msg string like a smi to avoid GC
// problems, however msg is not guaranteed to be aligned // problems, however msg is not guaranteed to be aligned
......
...@@ -66,6 +66,16 @@ class MacroAssembler: public Assembler { ...@@ -66,6 +66,16 @@ class MacroAssembler: public Assembler {
public: public:
MacroAssembler(void* buffer, int size); MacroAssembler(void* buffer, int size);
// ---------------------------------------------------------------------------
// x64 Implementation Support
// Test the MacroAssembler by constructing and calling a simple JSFunction.
// Cannot be done using API because this must be done in the middle of the
// bootstrapping process.
// TODO(X64): Remove once we can get through the bootstrapping process.
static void ConstructAndTestJSFunction();
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// GC Support // GC Support
......
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