Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/runtime/runtime-wasm.cc

Issue 2590563002: [wasm] Cleanup unneeded casts to WasmInstanceObject (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/frames.cc ('k') | src/wasm/wasm-module.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/assembler.h" 8 #include "src/assembler.h"
9 #include "src/compiler/wasm-compiler.h" 9 #include "src/compiler/wasm-compiler.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
11 #include "src/debug/debug.h" 11 #include "src/debug/debug.h"
12 #include "src/factory.h" 12 #include "src/factory.h"
13 #include "src/frames-inl.h" 13 #include "src/frames-inl.h"
14 #include "src/objects-inl.h" 14 #include "src/objects-inl.h"
15 #include "src/v8memory.h" 15 #include "src/v8memory.h"
16 #include "src/wasm/wasm-module.h" 16 #include "src/wasm/wasm-module.h"
17 #include "src/wasm/wasm-objects.h" 17 #include "src/wasm/wasm-objects.h"
18 #include "src/wasm/wasm-opcodes.h" 18 #include "src/wasm/wasm-opcodes.h"
19 19
20 namespace v8 { 20 namespace v8 {
21 namespace internal { 21 namespace internal {
22 22
23 namespace {
24 Handle<WasmInstanceObject> GetWasmInstanceOnStackTop(Isolate* isolate) {
25 DisallowHeapAllocation no_allocation;
26 const Address entry = Isolate::c_entry_fp(isolate->thread_local_top());
27 Address pc =
28 Memory::Address_at(entry + StandardFrameConstants::kCallerPCOffset);
29 Code* code = isolate->inner_pointer_to_code_cache()->GetCacheEntry(pc)->code;
30 DCHECK_EQ(Code::WASM_FUNCTION, code->kind());
31 WasmInstanceObject* owning_instance = wasm::GetOwningWasmInstance(code);
32 CHECK_NOT_NULL(owning_instance);
33 return handle(owning_instance, isolate);
34 }
35 } // namespace
36
23 RUNTIME_FUNCTION(Runtime_WasmMemorySize) { 37 RUNTIME_FUNCTION(Runtime_WasmMemorySize) {
24 HandleScope scope(isolate); 38 HandleScope scope(isolate);
25 DCHECK_EQ(0, args.length()); 39 DCHECK_EQ(0, args.length());
26 40
27 Handle<WasmInstanceObject> instance; 41 Handle<WasmInstanceObject> instance = GetWasmInstanceOnStackTop(isolate);
28 {
29 // Get the module JSObject
30 DisallowHeapAllocation no_allocation;
31 const Address entry = Isolate::c_entry_fp(isolate->thread_local_top());
32 Address pc =
33 Memory::Address_at(entry + StandardFrameConstants::kCallerPCOffset);
34 Code* code =
35 isolate->inner_pointer_to_code_cache()->GetCacheEntry(pc)->code;
36 WasmInstanceObject* owning_instance = wasm::GetOwningWasmInstance(code);
37 CHECK_NOT_NULL(owning_instance);
38 instance = handle(owning_instance, isolate);
39 }
40 return *isolate->factory()->NewNumberFromInt( 42 return *isolate->factory()->NewNumberFromInt(
41 wasm::GetInstanceMemorySize(isolate, instance)); 43 wasm::GetInstanceMemorySize(isolate, instance));
42 } 44 }
43 45
44 RUNTIME_FUNCTION(Runtime_WasmGrowMemory) { 46 RUNTIME_FUNCTION(Runtime_WasmGrowMemory) {
45 HandleScope scope(isolate); 47 HandleScope scope(isolate);
46 DCHECK_EQ(1, args.length()); 48 DCHECK_EQ(1, args.length());
47 CONVERT_UINT32_ARG_CHECKED(delta_pages, 0); 49 CONVERT_UINT32_ARG_CHECKED(delta_pages, 0);
48 Handle<WasmInstanceObject> instance; 50 Handle<WasmInstanceObject> instance = GetWasmInstanceOnStackTop(isolate);
49 {
50 // Get the module JSObject
51 DisallowHeapAllocation no_allocation;
52 const Address entry = Isolate::c_entry_fp(isolate->thread_local_top());
53 Address pc =
54 Memory::Address_at(entry + StandardFrameConstants::kCallerPCOffset);
55 Code* code =
56 isolate->inner_pointer_to_code_cache()->GetCacheEntry(pc)->code;
57 WasmInstanceObject* owning_instance = wasm::GetOwningWasmInstance(code);
58 CHECK_NOT_NULL(owning_instance);
59 instance = handle(owning_instance, isolate);
60 }
61 return *isolate->factory()->NewNumberFromInt( 51 return *isolate->factory()->NewNumberFromInt(
62 wasm::GrowMemory(isolate, instance, delta_pages)); 52 wasm::GrowMemory(isolate, instance, delta_pages));
63 } 53 }
64 54
65 Object* ThrowRuntimeError(Isolate* isolate, int message_id, int byte_offset, 55 Object* ThrowRuntimeError(Isolate* isolate, int message_id, int byte_offset,
66 bool patch_source_position) { 56 bool patch_source_position) {
67 HandleScope scope(isolate); 57 HandleScope scope(isolate);
68 Handle<Object> error_obj = isolate->factory()->NewWasmRuntimeError( 58 Handle<Object> error_obj = isolate->factory()->NewWasmRuntimeError(
69 static_cast<MessageTemplate::Template>(message_id)); 59 static_cast<MessageTemplate::Template>(message_id));
70 60
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 Object* exception = args[0]; 147 Object* exception = args[0];
158 // The unwinder will only deliver exceptions to wasm if the exception is a 148 // The unwinder will only deliver exceptions to wasm if the exception is a
159 // Number or a Smi (which we have just converted to a Number.) This logic 149 // Number or a Smi (which we have just converted to a Number.) This logic
160 // lives in Isolate::is_catchable_by_wasm(Object*). 150 // lives in Isolate::is_catchable_by_wasm(Object*).
161 CHECK(exception->IsNumber()); 151 CHECK(exception->IsNumber());
162 return exception; 152 return exception;
163 } 153 }
164 154
165 } // namespace internal 155 } // namespace internal
166 } // namespace v8 156 } // namespace v8
OLDNEW
« no previous file with comments | « src/frames.cc ('k') | src/wasm/wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698