Cleanup: shared isolate
BUG= Review-Url: https://codereview.chromium.org/1993233002 Cr-Commit-Position: refs/heads/master@{#36394}
This commit is contained in:
parent
584386a2d9
commit
ec2c5a037a
@ -318,8 +318,7 @@ bool AllocateGlobals(ErrorThrower* thrower, Isolate* isolate,
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
WasmModule::WasmModule()
|
WasmModule::WasmModule()
|
||||||
: shared_isolate(nullptr),
|
: module_start(nullptr),
|
||||||
module_start(nullptr),
|
|
||||||
module_end(nullptr),
|
module_end(nullptr),
|
||||||
min_mem_pages(0),
|
min_mem_pages(0),
|
||||||
max_mem_pages(0),
|
max_mem_pages(0),
|
||||||
@ -626,7 +625,6 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
|
|||||||
Handle<JSArrayBuffer> memory) {
|
Handle<JSArrayBuffer> memory) {
|
||||||
HistogramTimerScope wasm_instantiate_module_time_scope(
|
HistogramTimerScope wasm_instantiate_module_time_scope(
|
||||||
isolate->counters()->wasm_instantiate_module_time());
|
isolate->counters()->wasm_instantiate_module_time());
|
||||||
this->shared_isolate = isolate; // TODO(titzer): have a real shared isolate.
|
|
||||||
ErrorThrower thrower(isolate, "WasmModule::Instantiate()");
|
ErrorThrower thrower(isolate, "WasmModule::Instantiate()");
|
||||||
Factory* factory = isolate->factory();
|
Factory* factory = isolate->factory();
|
||||||
|
|
||||||
|
@ -159,7 +159,6 @@ struct WasmModule {
|
|||||||
static const uint32_t kMinMemPages = 1; // Minimum memory size = 64kb
|
static const uint32_t kMinMemPages = 1; // Minimum memory size = 64kb
|
||||||
static const uint32_t kMaxMemPages = 16384; // Maximum memory size = 1gb
|
static const uint32_t kMaxMemPages = 16384; // Maximum memory size = 1gb
|
||||||
|
|
||||||
Isolate* shared_isolate; // isolate for storing shared code.
|
|
||||||
const byte* module_start; // starting address for the module bytes.
|
const byte* module_start; // starting address for the module bytes.
|
||||||
const byte* module_end; // end address for the module bytes.
|
const byte* module_end; // end address for the module bytes.
|
||||||
uint32_t min_mem_pages; // minimum size of the memory in 64k pages.
|
uint32_t min_mem_pages; // minimum size of the memory in 64k pages.
|
||||||
|
@ -72,8 +72,10 @@ const uint32_t kMaxGlobalsSize = 128;
|
|||||||
// {WasmModuleInstance}.
|
// {WasmModuleInstance}.
|
||||||
class TestingModule : public ModuleEnv {
|
class TestingModule : public ModuleEnv {
|
||||||
public:
|
public:
|
||||||
TestingModule() : instance_(&module_), global_offset(0) {
|
TestingModule()
|
||||||
module_.shared_isolate = CcTest::InitIsolateOnce();
|
: instance_(&module_),
|
||||||
|
isolate_(CcTest::InitIsolateOnce()),
|
||||||
|
global_offset(0) {
|
||||||
module = &module_;
|
module = &module_;
|
||||||
instance = &instance_;
|
instance = &instance_;
|
||||||
instance->module = &module_;
|
instance->module = &module_;
|
||||||
@ -178,23 +180,21 @@ class TestingModule : public ModuleEnv {
|
|||||||
Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
|
Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
|
||||||
*v8::Local<v8::Function>::Cast(CompileRun(source))));
|
*v8::Local<v8::Function>::Cast(CompileRun(source))));
|
||||||
uint32_t index = AddFunction(sig, Handle<Code>::null());
|
uint32_t index = AddFunction(sig, Handle<Code>::null());
|
||||||
Isolate* isolate = module->shared_isolate;
|
|
||||||
WasmName module_name = ArrayVector("test");
|
WasmName module_name = ArrayVector("test");
|
||||||
WasmName function_name;
|
WasmName function_name;
|
||||||
Handle<Code> code = CompileWasmToJSWrapper(isolate, this, jsfunc, sig,
|
Handle<Code> code = CompileWasmToJSWrapper(isolate_, this, jsfunc, sig,
|
||||||
module_name, function_name);
|
module_name, function_name);
|
||||||
instance->function_code[index] = code;
|
instance->function_code[index] = code;
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle<JSFunction> WrapCode(uint32_t index) {
|
Handle<JSFunction> WrapCode(uint32_t index) {
|
||||||
Isolate* isolate = module->shared_isolate;
|
|
||||||
// Wrap the code so it can be called as a JS function.
|
// Wrap the code so it can be called as a JS function.
|
||||||
Handle<String> name = isolate->factory()->NewStringFromStaticChars("main");
|
Handle<String> name = isolate_->factory()->NewStringFromStaticChars("main");
|
||||||
Handle<JSObject> module_object = Handle<JSObject>(0, isolate);
|
Handle<JSObject> module_object = Handle<JSObject>(0, isolate_);
|
||||||
Handle<Code> code = instance->function_code[index];
|
Handle<Code> code = instance->function_code[index];
|
||||||
WasmJs::InstallWasmFunctionMap(isolate, isolate->native_context());
|
WasmJs::InstallWasmFunctionMap(isolate_, isolate_->native_context());
|
||||||
return compiler::CompileJSToWasmWrapper(isolate, this, name, code,
|
return compiler::CompileJSToWasmWrapper(isolate_, this, name, code,
|
||||||
module_object, index);
|
module_object, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,9 +203,8 @@ class TestingModule : public ModuleEnv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AddIndirectFunctionTable(int* functions, int table_size) {
|
void AddIndirectFunctionTable(int* functions, int table_size) {
|
||||||
Isolate* isolate = module->shared_isolate;
|
|
||||||
Handle<FixedArray> fixed =
|
Handle<FixedArray> fixed =
|
||||||
isolate->factory()->NewFixedArray(2 * table_size);
|
isolate_->factory()->NewFixedArray(2 * table_size);
|
||||||
instance->function_table = fixed;
|
instance->function_table = fixed;
|
||||||
DCHECK_EQ(0u, module->function_table.size());
|
DCHECK_EQ(0u, module->function_table.size());
|
||||||
for (int i = 0; i < table_size; i++) {
|
for (int i = 0; i < table_size; i++) {
|
||||||
@ -228,6 +227,7 @@ class TestingModule : public ModuleEnv {
|
|||||||
private:
|
private:
|
||||||
WasmModule module_;
|
WasmModule module_;
|
||||||
WasmModuleInstance instance_;
|
WasmModuleInstance instance_;
|
||||||
|
Isolate* isolate_;
|
||||||
uint32_t global_offset;
|
uint32_t global_offset;
|
||||||
V8_ALIGNED(8) byte global_data[kMaxGlobalsSize]; // preallocated global data.
|
V8_ALIGNED(8) byte global_data[kMaxGlobalsSize]; // preallocated global data.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user