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

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

Issue 2637643002: [wasm] Table.Grow should grow dispatch tables (Closed)
Patch Set: Rebase + review 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
« no previous file with comments | « no previous file | 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 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 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 } 539 }
540 new_size64 += old_size; 540 new_size64 += old_size;
541 541
542 if (new_size64 < old_size || new_size64 > receiver->maximum_length()) { 542 if (new_size64 < old_size || new_size64 > receiver->maximum_length()) {
543 v8::Local<v8::Value> e = v8::Exception::RangeError( 543 v8::Local<v8::Value> e = v8::Exception::RangeError(
544 v8_str(isolate, new_size64 < old_size ? "trying to shrink table" 544 v8_str(isolate, new_size64 < old_size ? "trying to shrink table"
545 : "maximum table size exceeded")); 545 : "maximum table size exceeded"));
546 isolate->ThrowException(e); 546 isolate->ThrowException(e);
547 return; 547 return;
548 } 548 }
549
549 int new_size = static_cast<int>(new_size64); 550 int new_size = static_cast<int>(new_size64);
551 i::WasmTableObject::Grow(i_isolate, receiver,
552 static_cast<uint32_t>(new_size - old_size));
550 553
551 if (new_size != old_size) { 554 if (new_size != old_size) {
552 i::Handle<i::FixedArray> new_array = 555 i::Handle<i::FixedArray> new_array =
553 i_isolate->factory()->NewFixedArray(new_size); 556 i_isolate->factory()->NewFixedArray(new_size);
554 for (int i = 0; i < old_size; ++i) new_array->set(i, old_array->get(i)); 557 for (int i = 0; i < old_size; ++i) new_array->set(i, old_array->get(i));
555 i::Object* null = i_isolate->heap()->null_value(); 558 i::Object* null = i_isolate->heap()->null_value();
556 for (int i = old_size; i < new_size; ++i) new_array->set(i, null); 559 for (int i = old_size; i < new_size; ++i) new_array->set(i, null);
557 receiver->set_functions(*new_array); 560 receiver->set_functions(*new_array);
558 } 561 }
559 562
560 // TODO(titzer): update relevant instances. 563 // TODO(gdeepti): use weak links for instances
564 v8::ReturnValue<v8::Value> return_value = args.GetReturnValue();
565 return_value.Set(old_size);
561 } 566 }
562 567
563 void WebAssemblyTableGet(const v8::FunctionCallbackInfo<v8::Value>& args) { 568 void WebAssemblyTableGet(const v8::FunctionCallbackInfo<v8::Value>& args) {
564 v8::Isolate* isolate = args.GetIsolate(); 569 v8::Isolate* isolate = args.GetIsolate();
565 Local<Context> context = isolate->GetCurrentContext(); 570 Local<Context> context = isolate->GetCurrentContext();
566 i::Handle<i::Context> i_context = Utils::OpenHandle(*context); 571 i::Handle<i::Context> i_context = Utils::OpenHandle(*context);
567 if (!BrandCheck(isolate, Utils::OpenHandle(*args.This()), 572 if (!BrandCheck(isolate, Utils::OpenHandle(*args.This()),
568 i::Handle<i::Symbol>(i_context->wasm_table_sym()), 573 i::Handle<i::Symbol>(i_context->wasm_table_sym()),
569 "Receiver is not a WebAssembly.Table")) { 574 "Receiver is not a WebAssembly.Table")) {
570 return; 575 return;
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 i::Handle<i::Symbol> symbol(isolate->context()->wasm_memory_sym(), isolate); 897 i::Handle<i::Symbol> symbol(isolate->context()->wasm_memory_sym(), isolate);
893 return HasBrand(value, symbol); 898 return HasBrand(value, symbol);
894 } 899 }
895 900
896 bool WasmJs::IsWasmTableObject(Isolate* isolate, Handle<Object> value) { 901 bool WasmJs::IsWasmTableObject(Isolate* isolate, Handle<Object> value) {
897 i::Handle<i::Symbol> symbol(isolate->context()->wasm_table_sym(), isolate); 902 i::Handle<i::Symbol> symbol(isolate->context()->wasm_table_sym(), isolate);
898 return HasBrand(value, symbol); 903 return HasBrand(value, symbol);
899 } 904 }
900 } // namespace internal 905 } // namespace internal
901 } // namespace v8 906 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/wasm/wasm-module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698