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

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

Issue 2626313003: [wasm] Change the constant kV8MaxWasmMemoryPages to a command line flag. (Closed)
Patch Set: allow all unsigned ints Created 3 years, 11 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
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-natives.h" 5 #include "src/api-natives.h"
6 #include "src/api.h" 6 #include "src/api.h"
7 #include "src/asmjs/asm-js.h" 7 #include "src/asmjs/asm-js.h"
8 #include "src/asmjs/asm-typer.h" 8 #include "src/asmjs/asm-typer.h"
9 #include "src/asmjs/asm-wasm-builder.h" 9 #include "src/asmjs/asm-wasm-builder.h"
10 #include "src/assert-scope.h" 10 #include "src/assert-scope.h"
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 if (args.Length() < 1 || !args[0]->IsObject()) { 444 if (args.Length() < 1 || !args[0]->IsObject()) {
445 thrower.TypeError("Argument 0 must be a memory descriptor"); 445 thrower.TypeError("Argument 0 must be a memory descriptor");
446 return; 446 return;
447 } 447 }
448 Local<Context> context = isolate->GetCurrentContext(); 448 Local<Context> context = isolate->GetCurrentContext();
449 Local<v8::Object> descriptor = args[0]->ToObject(context).ToLocalChecked(); 449 Local<v8::Object> descriptor = args[0]->ToObject(context).ToLocalChecked();
450 // The descriptor's 'initial'. 450 // The descriptor's 'initial'.
451 int initial = 0; 451 int initial = 0;
452 if (!GetIntegerProperty(isolate, &thrower, context, descriptor, 452 if (!GetIntegerProperty(isolate, &thrower, context, descriptor,
453 v8_str(isolate, "initial"), &initial, 0, 453 v8_str(isolate, "initial"), &initial, 0,
454 i::wasm::kV8MaxWasmMemoryPages)) { 454 i::FLAG_wasm_max_mem_pages)) {
455 return; 455 return;
456 } 456 }
457 // The descriptor's 'maximum'. 457 // The descriptor's 'maximum'.
458 int maximum = -1; 458 int maximum = -1;
459 Local<String> maximum_key = v8_str(isolate, "maximum"); 459 Local<String> maximum_key = v8_str(isolate, "maximum");
460 Maybe<bool> has_maximum = descriptor->Has(context, maximum_key); 460 Maybe<bool> has_maximum = descriptor->Has(context, maximum_key);
461 461
462 if (!has_maximum.IsNothing() && has_maximum.FromJust()) { 462 if (!has_maximum.IsNothing() && has_maximum.FromJust()) {
463 if (!GetIntegerProperty(isolate, &thrower, context, descriptor, maximum_key, 463 if (!GetIntegerProperty(isolate, &thrower, context, descriptor, maximum_key,
464 &maximum, initial, 464 &maximum, initial,
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 v8::Local<v8::Value> e = v8::Exception::TypeError( 643 v8::Local<v8::Value> e = v8::Exception::TypeError(
644 v8_str(isolate, "Argument 0 required, must be numeric value of pages")); 644 v8_str(isolate, "Argument 0 required, must be numeric value of pages"));
645 isolate->ThrowException(e); 645 isolate->ThrowException(e);
646 return; 646 return;
647 } 647 }
648 i::Handle<i::WasmMemoryObject> receiver = 648 i::Handle<i::WasmMemoryObject> receiver =
649 i::Handle<i::WasmMemoryObject>::cast(Utils::OpenHandle(*args.This())); 649 i::Handle<i::WasmMemoryObject>::cast(Utils::OpenHandle(*args.This()));
650 int64_t max_size64 = receiver->maximum_pages(); 650 int64_t max_size64 = receiver->maximum_pages();
651 if (max_size64 < 0 || 651 if (max_size64 < 0 ||
652 max_size64 > static_cast<int64_t>(i::wasm::kV8MaxWasmTableSize)) { 652 max_size64 > static_cast<int64_t>(i::wasm::kV8MaxWasmTableSize)) {
653 max_size64 = i::wasm::kV8MaxWasmMemoryPages; 653 max_size64 = i::FLAG_wasm_max_mem_pages;
654 } 654 }
655 i::Handle<i::JSArrayBuffer> old_buffer(receiver->buffer()); 655 i::Handle<i::JSArrayBuffer> old_buffer(receiver->buffer());
656 uint32_t old_size = 656 uint32_t old_size =
657 old_buffer->byte_length()->Number() / i::wasm::kSpecMaxWasmMemoryPages; 657 old_buffer->byte_length()->Number() / i::wasm::kSpecMaxWasmMemoryPages;
658 int64_t new_size64 = old_size + delta_size; 658 int64_t new_size64 = old_size + delta_size;
659 if (delta_size < 0 || max_size64 < new_size64 || new_size64 < old_size) { 659 if (delta_size < 0 || max_size64 < new_size64 || new_size64 < old_size) {
660 v8::Local<v8::Value> e = v8::Exception::RangeError(v8_str( 660 v8::Local<v8::Value> e = v8::Exception::RangeError(v8_str(
661 isolate, new_size64 < old_size ? "trying to shrink memory" 661 isolate, new_size64 < old_size ? "trying to shrink memory"
662 : "maximum memory size exceeded")); 662 : "maximum memory size exceeded"));
663 isolate->ThrowException(e); 663 isolate->ThrowException(e);
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 i::Handle<i::Symbol> symbol(isolate->context()->wasm_memory_sym(), isolate); 903 i::Handle<i::Symbol> symbol(isolate->context()->wasm_memory_sym(), isolate);
904 return HasBrand(value, symbol); 904 return HasBrand(value, symbol);
905 } 905 }
906 906
907 bool WasmJs::IsWasmTableObject(Isolate* isolate, Handle<Object> value) { 907 bool WasmJs::IsWasmTableObject(Isolate* isolate, Handle<Object> value) {
908 i::Handle<i::Symbol> symbol(isolate->context()->wasm_table_sym(), isolate); 908 i::Handle<i::Symbol> symbol(isolate->context()->wasm_table_sym(), isolate);
909 return HasBrand(value, symbol); 909 return HasBrand(value, symbol);
910 } 910 }
911 } // namespace internal 911 } // namespace internal
912 } // namespace v8 912 } // namespace v8
OLDNEW
« src/flags.cc ('K') | « src/wasm/wasm-interpreter.cc ('k') | src/wasm/wasm-limits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698