OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |