Chromium Code Reviews| 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 | 7 | 
| 7 #include "src/wasm/module-decoder.h" | 8 #include "src/wasm/module-decoder.h" | 
| 8 #include "src/wasm/wasm-module.h" | 9 #include "src/wasm/wasm-module.h" | 
| 9 #include "src/wasm/wasm-text.h" | 10 #include "src/wasm/wasm-text.h" | 
| 10 | 11 | 
| 11 #define TRACE(...) \ | 12 #define TRACE(...) \ | 
| 12 do { \ | 13 do { \ | 
| 13 if (FLAG_trace_wasm_instances) PrintF(__VA_ARGS__); \ | 14 if (FLAG_trace_wasm_instances) PrintF(__VA_ARGS__); \ | 
| 14 } while (false) | 15 } while (false) | 
| 15 | 16 | 
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 | 301 | 
| 301 WasmExportedFunction* WasmExportedFunction::cast(Object* object) { | 302 WasmExportedFunction* WasmExportedFunction::cast(Object* object) { | 
| 302 DCHECK(object && object->IsJSFunction()); | 303 DCHECK(object && object->IsJSFunction()); | 
| 303 DCHECK_EQ(Code::JS_TO_WASM_FUNCTION, | 304 DCHECK_EQ(Code::JS_TO_WASM_FUNCTION, | 
| 304 JSFunction::cast(object)->code()->kind()); | 305 JSFunction::cast(object)->code()->kind()); | 
| 305 // TODO(titzer): brand check for WasmExportedFunction. | 306 // TODO(titzer): brand check for WasmExportedFunction. | 
| 306 return reinterpret_cast<WasmExportedFunction*>(object); | 307 return reinterpret_cast<WasmExportedFunction*>(object); | 
| 307 } | 308 } | 
| 308 | 309 | 
| 309 Handle<WasmExportedFunction> WasmExportedFunction::New( | 310 Handle<WasmExportedFunction> WasmExportedFunction::New( | 
| 310 Isolate* isolate, Handle<WasmInstanceObject> instance, Handle<String> name, | 311 Isolate* isolate, Handle<WasmInstanceObject> instance, | 
| 311 Handle<Code> export_wrapper, int arity, int func_index) { | 312 MaybeHandle<String> maybe_name, int func_index, int arity, | 
| 313 Handle<Code> export_wrapper) { | |
| 314 ScopedVector<char> buffer(16); | |
| 
 
bradnelson
2016/12/06 15:28:31
But you can have up to 19 digits in 63-bit signed
 
 | |
| 315 int length = SNPrintF(buffer, "%d", func_index); | |
| 316 Handle<String> name; | |
| 317 if (maybe_name.is_null()) { | |
| 318 name = isolate->factory() | |
| 319 ->NewStringFromAscii( | |
| 320 Vector<const char>::cast(buffer.SubVector(0, length))) | |
| 321 .ToHandleChecked(); | |
| 322 } else { | |
| 323 name = maybe_name.ToHandleChecked(); | |
| 324 } | |
| 312 DCHECK_EQ(Code::JS_TO_WASM_FUNCTION, export_wrapper->kind()); | 325 DCHECK_EQ(Code::JS_TO_WASM_FUNCTION, export_wrapper->kind()); | 
| 313 Handle<SharedFunctionInfo> shared = | 326 Handle<SharedFunctionInfo> shared = | 
| 314 isolate->factory()->NewSharedFunctionInfo(name, export_wrapper, false); | 327 isolate->factory()->NewSharedFunctionInfo(name, export_wrapper, false); | 
| 315 shared->set_length(arity); | 328 shared->set_length(arity); | 
| 316 shared->set_internal_formal_parameter_count(arity); | 329 shared->set_internal_formal_parameter_count(arity); | 
| 317 Handle<JSFunction> function = isolate->factory()->NewFunction( | 330 Handle<JSFunction> function = isolate->factory()->NewFunction( | 
| 318 isolate->wasm_function_map(), name, export_wrapper); | 331 isolate->wasm_function_map(), name, export_wrapper); | 
| 319 function->set_shared(*shared); | 332 function->set_shared(*shared); | 
| 320 | 333 | 
| 321 function->SetInternalField(kInstance, *instance); | 334 function->SetInternalField(kInstance, *instance); | 
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 584 !array->get(kPreviousInstanceWrapper)->IsFixedArray()) | 597 !array->get(kPreviousInstanceWrapper)->IsFixedArray()) | 
| 585 return false; | 598 return false; | 
| 586 return true; | 599 return true; | 
| 587 } | 600 } | 
| 588 | 601 | 
| 589 void WasmInstanceWrapper::set_instance_object(Handle<JSObject> instance, | 602 void WasmInstanceWrapper::set_instance_object(Handle<JSObject> instance, | 
| 590 Isolate* isolate) { | 603 Isolate* isolate) { | 
| 591 Handle<WeakCell> cell = isolate->factory()->NewWeakCell(instance); | 604 Handle<WeakCell> cell = isolate->factory()->NewWeakCell(instance); | 
| 592 set(kWrapperInstanceObject, *cell); | 605 set(kWrapperInstanceObject, *cell); | 
| 593 } | 606 } | 
| OLD | NEW |