Disable x64 disassembler under win32.

Add x64 assembler macros.
Review URL: http://codereview.chromium.org//8760015

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1955 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
regis@google.com 2011-11-30 23:55:30 +00:00
parent 41b75c295f
commit e27623a4ef
5 changed files with 105 additions and 1 deletions

View file

@ -8,7 +8,7 @@
#if defined(TARGET_ARCH_IA32)
#include "vm/assembler_macros_ia32.h"
#elif defined(TARGET_ARCH_X64)
// Not yet implemented.
#include "vm/assembler_macros_x64.h"
#elif defined(TARGET_ARCH_ARM)
// Not yet implemented.
#else

View file

@ -0,0 +1,58 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/globals.h"
#if defined(TARGET_ARCH_X64)
#include "vm/assembler_macros.h"
#include "vm/assembler.h"
namespace dart {
DECLARE_FLAG(bool, inline_alloc);
#define __ assembler->
// Static.
void AssemblerMacros::TryAllocate(Assembler* assembler,
const Class& cls,
Register class_reg,
Label* failure,
Register instance_reg) {
#if defined(DEBUG)
__ Untested("AssemblerMacros::TryAllocate");
Label ok;
__ LoadObject(instance_reg, cls);
__ cmpl(instance_reg, class_reg);
__ j(EQUAL, &ok, Assembler::kNearJump);
__ Stop("AssemblerMacros::TryAllocate, wrong arguments");
__ Bind(&ok);
#endif
ASSERT(failure != NULL);
ASSERT(class_reg != instance_reg);
if (FLAG_inline_alloc) {
Heap* heap = Isolate::Current()->heap();
const intptr_t instance_size = cls.instance_size();
__ movq(instance_reg, Address::Absolute(heap->TopAddress()));
__ addq(instance_reg, Immediate(instance_size));
// instance_reg: potential next object start.
__ cmpq(instance_reg, Address::Absolute(heap->EndAddress()));
__ j(ABOVE_EQUAL, failure, Assembler::kNearJump);
// Successfully allocated the object, now update top to point to
// next object start and store the class in the class field of object.
__ movq(Address::Absolute(heap->TopAddress()), instance_reg);
ASSERT(instance_size >= kHeapObjectTag);
__ subq(instance_reg, Immediate(instance_size - kHeapObjectTag));
__ movq(FieldAddress(instance_reg, Instance::class_offset()), class_reg);
} else {
__ jmp(failure);
}
}
#undef __
} // namespace dart
#endif // defined TARGET_ARCH_X64

View file

@ -0,0 +1,40 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// The class 'AssemblerMacros' contains assembler instruction groups that
// are used in Dart.
#ifndef VM_ASSEMBLER_MACROS_X64_H_
#define VM_ASSEMBLER_MACROS_X64_H_
#ifndef VM_ASSEMBLER_MACROS_H_
#error Do not include assembler_macros_x64.h directly; use assembler_macros.h.
#endif
#include "vm/allocation.h"
#include "vm/constants_x64.h"
namespace dart {
// Forward declarations.
class Assembler;
class Class;
class Label;
class AssemblerMacros : public AllStatic {
public:
// Inlined allocation of an instance of class 'cls', code has no runtime
// calls. Jump to 'failure' if the instance cannot be allocated here.
// Class must be loaded in 'class_reg'. Allocated instance is returned
// in 'instance_reg'. Only the class field of the object is initialized.
// 'class_reg' and 'instance_reg' may not be the same register.
static void TryAllocate(Assembler* assembler,
const Class& cls,
Register class_reg,
Label* failure,
Register instance_reg);
};
} // namespace dart.
#endif // VM_ASSEMBLER_MACROS_X64_H_

View file

@ -2,10 +2,12 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#if !defined(_WIN32) // Disassembler is not yet supported under WIN32.
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#endif
#include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
#if defined(TARGET_ARCH_X64)
@ -23,6 +25,7 @@ void Disassembler::Disassemble(uword start,
// being disassembled from.
formatter->Print("start: %p end: %p\n", start, end);
#if !defined(_WIN32) // Disassembler is not yet supported under WIN32.
// Write code block to tmp file.
char tmp[] = "/tmp/codeblock.XXXXXX";
int fd = mkstemp(tmp);
@ -92,6 +95,7 @@ void Disassembler::Disassemble(uword start,
snprintf(tmp_o, sizeof(tmp_o), "%s.o", tmp);
remove(tmp_o);
#endif
#endif // !defined(_WIN32)
}

View file

@ -18,6 +18,8 @@
'assembler_macros.h',
'assembler_macros_ia32.cc',
'assembler_macros_ia32.h',
'assembler_macros_x64.cc',
'assembler_macros_x64.h',
'assembler_x64.cc',
'assembler_x64.h',
'assembler_x64_test.cc',