Fix multi-isolate build:
o Make ia32 macro assembler work without an isolate and use it in the custom memcpy creation code. o Remove isolate-dependent code from the custom memcpy and modulo functions creation code. Review URL: http://codereview.chromium.org/6788007 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7482 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
8099bf3531
commit
0b40589e73
@ -1594,10 +1594,11 @@ void Builtins::InitBuiltinFunctionTable() {
|
||||
|
||||
void Builtins::Setup(bool create_heap_objects) {
|
||||
ASSERT(!initialized_);
|
||||
Heap* heap = Isolate::Current()->heap();
|
||||
Isolate* isolate = Isolate::Current();
|
||||
Heap* heap = isolate->heap();
|
||||
|
||||
// Create a scope for the handles in the builtins.
|
||||
HandleScope scope;
|
||||
HandleScope scope(isolate);
|
||||
|
||||
const BuiltinDesc* functions = BuiltinFunctionTable::functions();
|
||||
|
||||
@ -1609,7 +1610,7 @@ void Builtins::Setup(bool create_heap_objects) {
|
||||
// separate code object for each one.
|
||||
for (int i = 0; i < builtin_count; i++) {
|
||||
if (create_heap_objects) {
|
||||
MacroAssembler masm(buffer, sizeof buffer);
|
||||
MacroAssembler masm(isolate, buffer, sizeof buffer);
|
||||
// Generate the code/adaptor.
|
||||
typedef void (*Generator)(MacroAssembler*, int, BuiltinExtraArguments);
|
||||
Generator g = FUNCTION_CAST<Generator>(functions[i].generator);
|
||||
@ -1634,7 +1635,7 @@ void Builtins::Setup(bool create_heap_objects) {
|
||||
}
|
||||
}
|
||||
// Log the event and add the code to the builtins array.
|
||||
PROFILE(ISOLATE,
|
||||
PROFILE(isolate,
|
||||
CodeCreateEvent(Logger::BUILTIN_TAG,
|
||||
Code::cast(code),
|
||||
functions[i].s_name));
|
||||
|
@ -95,7 +95,7 @@ Handle<Code> CodeStub::GetCode() {
|
||||
HandleScope scope(isolate);
|
||||
|
||||
// Generate the new code.
|
||||
MacroAssembler masm(NULL, 256);
|
||||
MacroAssembler masm(isolate, NULL, 256);
|
||||
GenerateCode(&masm);
|
||||
|
||||
// Create the code object.
|
||||
@ -132,7 +132,7 @@ MaybeObject* CodeStub::TryGetCode() {
|
||||
Code* code;
|
||||
if (!FindCodeInCache(&code)) {
|
||||
// Generate the new code.
|
||||
MacroAssembler masm(NULL, 256);
|
||||
MacroAssembler masm(Isolate::Current(), NULL, 256);
|
||||
GenerateCode(&masm);
|
||||
Heap* heap = masm.isolate()->heap();
|
||||
|
||||
|
@ -248,7 +248,7 @@ bool CodeGenerator::MakeCode(CompilationInfo* info) {
|
||||
MakeCodePrologue(info);
|
||||
// Generate code.
|
||||
const int kInitialBufferSize = 4 * KB;
|
||||
MacroAssembler masm(NULL, kInitialBufferSize);
|
||||
MacroAssembler masm(info->isolate(), NULL, kInitialBufferSize);
|
||||
#ifdef ENABLE_GDB_JIT_INTERFACE
|
||||
masm.positions_recorder()->StartGDBJITLineInfoRecording();
|
||||
#endif
|
||||
|
@ -933,7 +933,7 @@ LargeObjectChunk* Deoptimizer::CreateCode(BailoutType type) {
|
||||
// isn't meant to be serialized at all.
|
||||
ASSERT(!Serializer::enabled());
|
||||
|
||||
MacroAssembler masm(NULL, 16 * KB);
|
||||
MacroAssembler masm(Isolate::Current(), NULL, 16 * KB);
|
||||
masm.set_emit_debug_code(false);
|
||||
GenerateDeoptimizationEntries(&masm, kNumberOfEntries, type);
|
||||
CodeDesc desc;
|
||||
|
@ -286,7 +286,7 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info) {
|
||||
}
|
||||
CodeGenerator::MakeCodePrologue(info);
|
||||
const int kInitialBufferSize = 4 * KB;
|
||||
MacroAssembler masm(NULL, kInitialBufferSize);
|
||||
MacroAssembler masm(info->isolate(), NULL, kInitialBufferSize);
|
||||
#ifdef ENABLE_GDB_JIT_INTERFACE
|
||||
masm.positions_recorder()->StartGDBJITLineInfoRecording();
|
||||
#endif
|
||||
|
@ -606,7 +606,7 @@ Handle<Code> HGraph::Compile(CompilationInfo* info) {
|
||||
|
||||
if (!FLAG_use_lithium) return Handle<Code>::null();
|
||||
|
||||
MacroAssembler assembler(NULL, 0);
|
||||
MacroAssembler assembler(info->isolate(), NULL, 0);
|
||||
LCodeGen generator(chunk, &assembler, info);
|
||||
|
||||
if (FLAG_eliminate_empty_blocks) {
|
||||
|
@ -10176,14 +10176,13 @@ static void MemCopyWrapper(void* dest, const void* src, size_t size) {
|
||||
|
||||
|
||||
OS::MemCopyFunction CreateMemCopyFunction() {
|
||||
HandleScope scope;
|
||||
size_t actual_size;
|
||||
// Allocate buffer in executable space.
|
||||
byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB,
|
||||
&actual_size,
|
||||
true));
|
||||
if (buffer == NULL) return &MemCopyWrapper;
|
||||
MacroAssembler masm(buffer, static_cast<int>(actual_size));
|
||||
MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
|
||||
|
||||
// Generated code is put into a fixed, unmovable, buffer, and not into
|
||||
// the V8 heap. We can't, and don't, refer to any relocatable addresses
|
||||
|
@ -41,11 +41,14 @@ namespace internal {
|
||||
// -------------------------------------------------------------------------
|
||||
// MacroAssembler implementation.
|
||||
|
||||
MacroAssembler::MacroAssembler(void* buffer, int size)
|
||||
: Assembler(Isolate::Current(), buffer, size),
|
||||
MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size)
|
||||
: Assembler(arg_isolate, buffer, size),
|
||||
generating_stub_(false),
|
||||
allow_stub_calls_(true),
|
||||
code_object_(isolate()->heap()->undefined_value()) {
|
||||
allow_stub_calls_(true) {
|
||||
if (isolate() != NULL) {
|
||||
code_object_ = Handle<Object>(isolate()->heap()->undefined_value(),
|
||||
isolate());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2028,7 +2031,9 @@ void MacroAssembler::CallCFunction(Register function,
|
||||
|
||||
|
||||
CodePatcher::CodePatcher(byte* address, int size)
|
||||
: address_(address), size_(size), masm_(address, size + Assembler::kGap) {
|
||||
: address_(address),
|
||||
size_(size),
|
||||
masm_(Isolate::Current(), address, size + Assembler::kGap) {
|
||||
// Create a new macro assembler pointing to the address of the code to patch.
|
||||
// The size is adjusted with kGap on order for the assembler to generate size
|
||||
// bytes of instructions without failing with buffer size constraints.
|
||||
|
@ -56,7 +56,11 @@ class PostCallGenerator;
|
||||
// MacroAssembler implements a collection of frequently used macros.
|
||||
class MacroAssembler: public Assembler {
|
||||
public:
|
||||
MacroAssembler(void* buffer, int size);
|
||||
// The isolate parameter can be NULL if the macro assembler should
|
||||
// not use isolate-dependent functionality. In this case, it's the
|
||||
// responsibility of the caller to never invoke such function on the
|
||||
// macro assembler.
|
||||
MacroAssembler(Isolate* isolate, void* buffer, int size);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// GC Support
|
||||
@ -580,7 +584,10 @@ class MacroAssembler: public Assembler {
|
||||
|
||||
void Move(Register target, Handle<Object> value);
|
||||
|
||||
Handle<Object> CodeObject() { return code_object_; }
|
||||
Handle<Object> CodeObject() {
|
||||
ASSERT(!code_object_.is_null());
|
||||
return code_object_;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@ -99,7 +99,7 @@ namespace internal {
|
||||
RegExpMacroAssemblerIA32::RegExpMacroAssemblerIA32(
|
||||
Mode mode,
|
||||
int registers_to_save)
|
||||
: masm_(new MacroAssembler(NULL, kRegExpCodeSize)),
|
||||
: masm_(new MacroAssembler(Isolate::Current(), NULL, kRegExpCodeSize)),
|
||||
mode_(mode),
|
||||
num_registers_(registers_to_save),
|
||||
num_saved_registers_(registers_to_save),
|
||||
|
@ -215,13 +215,14 @@ OS::MemCopyFunction CreateMemCopyFunction();
|
||||
void OS::MemCopy(void* dest, const void* src, size_t size) {
|
||||
if (memcopy_function == NULL) {
|
||||
ScopedLock lock(memcopy_function_mutex);
|
||||
Isolate::EnsureDefaultIsolate();
|
||||
if (memcopy_function == NULL) {
|
||||
OS::MemCopyFunction temp = CreateMemCopyFunction();
|
||||
MemoryBarrier();
|
||||
memcopy_function = temp;
|
||||
}
|
||||
}
|
||||
// Note: here we rely on dependent reads being ordered. This is true
|
||||
// on all architectures we currently support.
|
||||
(*memcopy_function)(dest, src, size);
|
||||
#ifdef DEBUG
|
||||
CHECK_EQ(0, memcmp(dest, src, size));
|
||||
|
@ -186,13 +186,14 @@ OS::MemCopyFunction CreateMemCopyFunction();
|
||||
void OS::MemCopy(void* dest, const void* src, size_t size) {
|
||||
if (memcopy_function == NULL) {
|
||||
ScopedLock lock(memcopy_function_mutex);
|
||||
Isolate::EnsureDefaultIsolate();
|
||||
if (memcopy_function == NULL) {
|
||||
OS::MemCopyFunction temp = CreateMemCopyFunction();
|
||||
MemoryBarrier();
|
||||
memcopy_function = temp;
|
||||
}
|
||||
}
|
||||
// Note: here we rely on dependent reads being ordered. This is true
|
||||
// on all architectures we currently support.
|
||||
(*memcopy_function)(dest, src, size);
|
||||
#ifdef DEBUG
|
||||
CHECK_EQ(0, memcmp(dest, src, size));
|
||||
@ -210,13 +211,14 @@ ModuloFunction CreateModuloFunction();
|
||||
double modulo(double x, double y) {
|
||||
if (modulo_function == NULL) {
|
||||
ScopedLock lock(modulo_function_mutex);
|
||||
Isolate::EnsureDefaultIsolate();
|
||||
if (modulo_function == NULL) {
|
||||
ModuloFunction temp = CreateModuloFunction();
|
||||
MemoryBarrier();
|
||||
modulo_function = temp;
|
||||
}
|
||||
}
|
||||
// Note: here we rely on dependent reads being ordered. This is true
|
||||
// on all architectures we currently support.
|
||||
return (*modulo_function)(x, y);
|
||||
}
|
||||
#else // Win32
|
||||
|
@ -408,7 +408,8 @@ DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadPropertyWithInterceptor);
|
||||
// The stub compiler compiles stubs for the stub cache.
|
||||
class StubCompiler BASE_EMBEDDED {
|
||||
public:
|
||||
StubCompiler() : scope_(), masm_(NULL, 256), failure_(NULL) { }
|
||||
StubCompiler()
|
||||
: scope_(), masm_(Isolate::Current(), NULL, 256), failure_(NULL) { }
|
||||
|
||||
MUST_USE_RESULT MaybeObject* CompileCallInitialize(Code::Flags flags);
|
||||
MUST_USE_RESULT MaybeObject* CompileCallPreMonomorphic(Code::Flags flags);
|
||||
|
@ -345,7 +345,7 @@ TEST(AssemblerIa329) {
|
||||
InitializeVM();
|
||||
v8::HandleScope scope;
|
||||
v8::internal::byte buffer[256];
|
||||
MacroAssembler assm(buffer, sizeof buffer);
|
||||
MacroAssembler assm(Isolate::Current(), buffer, sizeof buffer);
|
||||
enum { kEqual = 0, kGreater = 1, kLess = 2, kNaN = 3, kUndefined = 4 };
|
||||
Label equal_l, less_l, greater_l, nan_l;
|
||||
__ fld_d(Operand(esp, 3 * kPointerSize));
|
||||
|
Loading…
Reference in New Issue
Block a user