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

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

Issue 1847543002: Expose a lower bound of malloc'd memory via heap statistics (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 8 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/wasm/module-decoder.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/api.h" 5 #include "src/api.h"
6 #include "src/api-natives.h" 6 #include "src/api-natives.h"
7 #include "src/assert-scope.h" 7 #include "src/assert-scope.h"
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/factory.h" 10 #include "src/factory.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 80
81 void VerifyModule(const v8::FunctionCallbackInfo<v8::Value>& args) { 81 void VerifyModule(const v8::FunctionCallbackInfo<v8::Value>& args) {
82 HandleScope scope(args.GetIsolate()); 82 HandleScope scope(args.GetIsolate());
83 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate()); 83 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate());
84 ErrorThrower thrower(isolate, "WASM.verifyModule()"); 84 ErrorThrower thrower(isolate, "WASM.verifyModule()");
85 85
86 RawBuffer buffer = GetRawBufferArgument(thrower, args); 86 RawBuffer buffer = GetRawBufferArgument(thrower, args);
87 if (thrower.error()) return; 87 if (thrower.error()) return;
88 88
89 i::Zone zone; 89 i::Zone zone(isolate->allocator());
90 internal::wasm::ModuleResult result = 90 internal::wasm::ModuleResult result =
91 internal::wasm::DecodeWasmModule(isolate, &zone, buffer.start, buffer.end, 91 internal::wasm::DecodeWasmModule(isolate, &zone, buffer.start, buffer.end,
92 true, internal::wasm::kWasmOrigin); 92 true, internal::wasm::kWasmOrigin);
93 93
94 if (result.failed()) { 94 if (result.failed()) {
95 thrower.Failed("", result); 95 thrower.Failed("", result);
96 } 96 }
97 97
98 if (result.val) delete result.val; 98 if (result.val) delete result.val;
99 } 99 }
100 100
101 101
102 void VerifyFunction(const v8::FunctionCallbackInfo<v8::Value>& args) { 102 void VerifyFunction(const v8::FunctionCallbackInfo<v8::Value>& args) {
103 HandleScope scope(args.GetIsolate()); 103 HandleScope scope(args.GetIsolate());
104 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate()); 104 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate());
105 ErrorThrower thrower(isolate, "WASM.verifyFunction()"); 105 ErrorThrower thrower(isolate, "WASM.verifyFunction()");
106 106
107 RawBuffer buffer = GetRawBufferArgument(thrower, args); 107 RawBuffer buffer = GetRawBufferArgument(thrower, args);
108 if (thrower.error()) return; 108 if (thrower.error()) return;
109 109
110 internal::wasm::FunctionResult result; 110 internal::wasm::FunctionResult result;
111 { 111 {
112 // Verification of a single function shouldn't allocate. 112 // Verification of a single function shouldn't allocate.
113 i::DisallowHeapAllocation no_allocation; 113 i::DisallowHeapAllocation no_allocation;
114 i::Zone zone; 114 i::Zone zone(isolate->allocator());
115 result = internal::wasm::DecodeWasmFunction(isolate, &zone, nullptr, 115 result = internal::wasm::DecodeWasmFunction(isolate, &zone, nullptr,
116 buffer.start, buffer.end); 116 buffer.start, buffer.end);
117 } 117 }
118 118
119 if (result.failed()) { 119 if (result.failed()) {
120 thrower.Failed("", result); 120 thrower.Failed("", result);
121 } 121 }
122 122
123 if (result.val) delete result.val; 123 if (result.val) delete result.val;
124 } 124 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 163
164 i::Handle<i::JSArrayBuffer> memory = i::Handle<i::JSArrayBuffer>::null(); 164 i::Handle<i::JSArrayBuffer> memory = i::Handle<i::JSArrayBuffer>::null();
165 if (args.Length() > 2 && args[2]->IsArrayBuffer()) { 165 if (args.Length() > 2 && args[2]->IsArrayBuffer()) {
166 Local<Object> obj = Local<Object>::Cast(args[2]); 166 Local<Object> obj = Local<Object>::Cast(args[2]);
167 i::Handle<i::Object> mem_obj = v8::Utils::OpenHandle(*obj); 167 i::Handle<i::Object> mem_obj = v8::Utils::OpenHandle(*obj);
168 memory = i::Handle<i::JSArrayBuffer>(i::JSArrayBuffer::cast(*mem_obj)); 168 memory = i::Handle<i::JSArrayBuffer>(i::JSArrayBuffer::cast(*mem_obj));
169 } 169 }
170 170
171 // Decode but avoid a redundant pass over function bodies for verification. 171 // Decode but avoid a redundant pass over function bodies for verification.
172 // Verification will happen during compilation. 172 // Verification will happen during compilation.
173 i::Zone zone; 173 i::Zone zone(isolate->allocator());
174 internal::wasm::ModuleResult result = internal::wasm::DecodeWasmModule( 174 internal::wasm::ModuleResult result = internal::wasm::DecodeWasmModule(
175 isolate, &zone, start, end, false, origin); 175 isolate, &zone, start, end, false, origin);
176 176
177 if (result.failed() && origin == internal::wasm::kAsmJsOrigin) { 177 if (result.failed() && origin == internal::wasm::kAsmJsOrigin) {
178 thrower->Error("Asm.js converted module failed to decode"); 178 thrower->Error("Asm.js converted module failed to decode");
179 } else if (result.failed()) { 179 } else if (result.failed()) {
180 thrower->Failed("", result); 180 thrower->Failed("", result);
181 } else { 181 } else {
182 // Success. Instantiate the module and return the object. 182 // Success. Instantiate the module and return the object.
183 i::Handle<i::JSObject> ffi = i::Handle<i::JSObject>::null(); 183 i::Handle<i::JSObject> ffi = i::Handle<i::JSObject>::null();
(...skipping 18 matching lines...) Expand all
202 HandleScope scope(args.GetIsolate()); 202 HandleScope scope(args.GetIsolate());
203 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate()); 203 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate());
204 ErrorThrower thrower(isolate, "WASM.instantiateModuleFromAsm()"); 204 ErrorThrower thrower(isolate, "WASM.instantiateModuleFromAsm()");
205 205
206 if (!args[0]->IsString()) { 206 if (!args[0]->IsString()) {
207 thrower.Error("Asm module text should be a string"); 207 thrower.Error("Asm module text should be a string");
208 return; 208 return;
209 } 209 }
210 210
211 i::Factory* factory = isolate->factory(); 211 i::Factory* factory = isolate->factory();
212 i::Zone zone; 212 i::Zone zone(isolate->allocator());
213 Local<String> source = Local<String>::Cast(args[0]); 213 Local<String> source = Local<String>::Cast(args[0]);
214 i::Handle<i::Script> script = factory->NewScript(Utils::OpenHandle(*source)); 214 i::Handle<i::Script> script = factory->NewScript(Utils::OpenHandle(*source));
215 i::ParseInfo info(&zone, script); 215 i::ParseInfo info(&zone, script);
216 216
217 i::Handle<i::Object> foreign; 217 i::Handle<i::Object> foreign;
218 if (args.Length() > 1 && args[1]->IsObject()) { 218 if (args.Length() > 1 && args[1]->IsObject()) {
219 Local<Object> local_foreign = Local<Object>::Cast(args[1]); 219 Local<Object> local_foreign = Local<Object>::Cast(args[1]);
220 foreign = v8::Utils::OpenHandle(*local_foreign); 220 foreign = v8::Utils::OpenHandle(*local_foreign);
221 } 221 }
222 222
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 int unused_property_fields = in_object_properties - pre_allocated; 317 int unused_property_fields = in_object_properties - pre_allocated;
318 Handle<Map> map = Map::CopyInitialMap( 318 Handle<Map> map = Map::CopyInitialMap(
319 prev_map, instance_size, in_object_properties, unused_property_fields); 319 prev_map, instance_size, in_object_properties, unused_property_fields);
320 320
321 context->set_wasm_function_map(*map); 321 context->set_wasm_function_map(*map);
322 } 322 }
323 } 323 }
324 324
325 } // namespace internal 325 } // namespace internal
326 } // namespace v8 326 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/module-decoder.cc ('k') | src/wasm/wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698