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

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

Issue 2386183004: [wasm] Call a runtime function for a MemorySize instruction. (Closed)
Patch Set: Comments addressed Created 4 years, 2 months 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/runtime/runtime.h ('k') | src/wasm/wasm-module.h » ('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 17
18 namespace v8 { 18 namespace v8 {
19 namespace internal { 19 namespace internal {
20 20
21 RUNTIME_FUNCTION(Runtime_WasmMemorySize) {
22 HandleScope scope(isolate);
23 DCHECK_EQ(0, args.length());
24
25 Handle<JSObject> module_instance;
26 {
27 // Get the module JSObject
28 DisallowHeapAllocation no_allocation;
29 const Address entry = Isolate::c_entry_fp(isolate->thread_local_top());
30 Address pc =
31 Memory::Address_at(entry + StandardFrameConstants::kCallerPCOffset);
32 Code* code =
33 isolate->inner_pointer_to_code_cache()->GetCacheEntry(pc)->code;
34 Object* owning_instance = wasm::GetOwningWasmInstance(code);
35 CHECK_NOT_NULL(owning_instance);
36 module_instance = handle(JSObject::cast(owning_instance), isolate);
37 }
38 return *isolate->factory()->NewNumberFromInt(
39 wasm::GetInstanceMemorySize(isolate, module_instance));
40 }
41
21 RUNTIME_FUNCTION(Runtime_WasmGrowMemory) { 42 RUNTIME_FUNCTION(Runtime_WasmGrowMemory) {
22 HandleScope scope(isolate); 43 HandleScope scope(isolate);
23 DCHECK_EQ(1, args.length()); 44 DCHECK_EQ(1, args.length());
24 CONVERT_UINT32_ARG_CHECKED(delta_pages, 0); 45 CONVERT_UINT32_ARG_CHECKED(delta_pages, 0);
25 Handle<JSObject> module_instance; 46 Handle<JSObject> module_instance;
26 { 47 {
27 // Get the module JSObject 48 // Get the module JSObject
28 DisallowHeapAllocation no_allocation; 49 DisallowHeapAllocation no_allocation;
29 const Address entry = Isolate::c_entry_fp(isolate->thread_local_top()); 50 const Address entry = Isolate::c_entry_fp(isolate->thread_local_top());
30 Address pc = 51 Address pc =
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 Object* exception = args[0]; 84 Object* exception = args[0];
64 // The unwinder will only deliver exceptions to wasm if the exception is a 85 // The unwinder will only deliver exceptions to wasm if the exception is a
65 // Number or a Smi (which we have just converted to a Number.) This logic 86 // Number or a Smi (which we have just converted to a Number.) This logic
66 // lives in Isolate::is_catchable_by_wasm(Object*). 87 // lives in Isolate::is_catchable_by_wasm(Object*).
67 CHECK(exception->IsNumber()); 88 CHECK(exception->IsNumber());
68 return exception; 89 return exception;
69 } 90 }
70 91
71 } // namespace internal 92 } // namespace internal
72 } // namespace v8 93 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698