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