| 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/wasm/wasm-objects.h" | 5 #include "src/wasm/wasm-objects.h" |
| 6 #include "src/utils.h" | 6 #include "src/utils.h" |
| 7 | 7 |
| 8 #include "src/debug/debug-interface.h" | 8 #include "src/debug/debug-interface.h" |
| 9 #include "src/wasm/module-decoder.h" | 9 #include "src/wasm/module-decoder.h" |
| 10 #include "src/wasm/wasm-module.h" | 10 #include "src/wasm/wasm-module.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 Handle<Symbol> table_sym(isolate->native_context()->wasm_table_sym()); | 141 Handle<Symbol> table_sym(isolate->native_context()->wasm_table_sym()); |
| 142 Object::SetProperty(table_obj, table_sym, table_obj, STRICT).Check(); | 142 Object::SetProperty(table_obj, table_sym, table_obj, STRICT).Check(); |
| 143 return Handle<WasmTableObject>::cast(table_obj); | 143 return Handle<WasmTableObject>::cast(table_obj); |
| 144 } | 144 } |
| 145 | 145 |
| 146 DEFINE_OBJ_GETTER(WasmTableObject, dispatch_tables, kDispatchTables, FixedArray) | 146 DEFINE_OBJ_GETTER(WasmTableObject, dispatch_tables, kDispatchTables, FixedArray) |
| 147 | 147 |
| 148 Handle<FixedArray> WasmTableObject::AddDispatchTable( | 148 Handle<FixedArray> WasmTableObject::AddDispatchTable( |
| 149 Isolate* isolate, Handle<WasmTableObject> table_obj, | 149 Isolate* isolate, Handle<WasmTableObject> table_obj, |
| 150 Handle<WasmInstanceObject> instance, int table_index, | 150 Handle<WasmInstanceObject> instance, int table_index, |
| 151 Handle<FixedArray> dispatch_table) { | 151 Handle<FixedArray> function_table, Handle<FixedArray> signature_table) { |
| 152 Handle<FixedArray> dispatch_tables( | 152 Handle<FixedArray> dispatch_tables( |
| 153 FixedArray::cast(table_obj->GetInternalField(kDispatchTables)), isolate); | 153 FixedArray::cast(table_obj->GetInternalField(kDispatchTables)), isolate); |
| 154 DCHECK_EQ(0, dispatch_tables->length() % 3); | 154 DCHECK_EQ(0, dispatch_tables->length() % 4); |
| 155 | 155 |
| 156 if (instance.is_null()) return dispatch_tables; | 156 if (instance.is_null()) return dispatch_tables; |
| 157 // TODO(titzer): use weak cells here to avoid leaking instances. | 157 // TODO(titzer): use weak cells here to avoid leaking instances. |
| 158 | 158 |
| 159 // Grow the dispatch table and add a new triple at the end. | 159 // Grow the dispatch table and add a new triple at the end. |
| 160 Handle<FixedArray> new_dispatch_tables = | 160 Handle<FixedArray> new_dispatch_tables = |
| 161 isolate->factory()->CopyFixedArrayAndGrow(dispatch_tables, 3); | 161 isolate->factory()->CopyFixedArrayAndGrow(dispatch_tables, 4); |
| 162 | 162 |
| 163 new_dispatch_tables->set(dispatch_tables->length() + 0, *instance); | 163 new_dispatch_tables->set(dispatch_tables->length() + 0, *instance); |
| 164 new_dispatch_tables->set(dispatch_tables->length() + 1, | 164 new_dispatch_tables->set(dispatch_tables->length() + 1, |
| 165 Smi::FromInt(table_index)); | 165 Smi::FromInt(table_index)); |
| 166 new_dispatch_tables->set(dispatch_tables->length() + 2, *dispatch_table); | 166 new_dispatch_tables->set(dispatch_tables->length() + 2, *function_table); |
| 167 new_dispatch_tables->set(dispatch_tables->length() + 3, *signature_table); |
| 167 | 168 |
| 168 table_obj->SetInternalField(WasmTableObject::kDispatchTables, | 169 table_obj->SetInternalField(WasmTableObject::kDispatchTables, |
| 169 *new_dispatch_tables); | 170 *new_dispatch_tables); |
| 170 | 171 |
| 171 return new_dispatch_tables; | 172 return new_dispatch_tables; |
| 172 } | 173 } |
| 173 | 174 |
| 174 DEFINE_OBJ_ACCESSORS(WasmTableObject, functions, kFunctions, FixedArray) | 175 DEFINE_OBJ_ACCESSORS(WasmTableObject, functions, kFunctions, FixedArray) |
| 175 | 176 |
| 176 uint32_t WasmTableObject::current_length() { return functions()->length(); } | 177 uint32_t WasmTableObject::current_length() { return functions()->length(); } |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 !array->get(kPreviousInstanceWrapper)->IsFixedArray()) | 836 !array->get(kPreviousInstanceWrapper)->IsFixedArray()) |
| 836 return false; | 837 return false; |
| 837 return true; | 838 return true; |
| 838 } | 839 } |
| 839 | 840 |
| 840 void WasmInstanceWrapper::set_instance_object(Handle<JSObject> instance, | 841 void WasmInstanceWrapper::set_instance_object(Handle<JSObject> instance, |
| 841 Isolate* isolate) { | 842 Isolate* isolate) { |
| 842 Handle<WeakCell> cell = isolate->factory()->NewWeakCell(instance); | 843 Handle<WeakCell> cell = isolate->factory()->NewWeakCell(instance); |
| 843 set(kWrapperInstanceObject, *cell); | 844 set(kWrapperInstanceObject, *cell); |
| 844 } | 845 } |
| OLD | NEW |