OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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-function-name-table.h" | 5 #include "src/wasm/wasm-function-name-table.h" |
6 #include "src/wasm/wasm-module.h" | 6 #include "src/wasm/wasm-module.h" |
7 | 7 |
8 #include "test/cctest/cctest.h" | 8 #include "test/cctest/cctest.h" |
9 | 9 |
10 using namespace v8::internal; | 10 using namespace v8::internal; |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 uint32_t func_index = 0; | 34 uint32_t func_index = 0; |
35 for (Vector<const char> name : names) { | 35 for (Vector<const char> name : names) { |
36 size_t name_offset = all_names.size(); | 36 size_t name_offset = all_names.size(); |
37 all_names.insert(all_names.end(), name.start(), | 37 all_names.insert(all_names.end(), name.start(), |
38 name.start() + name.length()); | 38 name.start() + name.length()); |
39 // Make every second function name null-terminated. | 39 // Make every second function name null-terminated. |
40 if (func_index % 2) all_names.push_back('\0'); | 40 if (func_index % 2) all_names.push_back('\0'); |
41 module.functions.push_back( | 41 module.functions.push_back( |
42 {nullptr, 0, 0, static_cast<uint32_t>(name_offset), | 42 {nullptr, 0, 0, static_cast<uint32_t>(name_offset), |
43 static_cast<uint32_t>(name.length()), 0, 0, 0, 0, 0, 0, false, false}); | 43 static_cast<uint32_t>(name.length()), 0, 0, 0, 0, 0, 0, false}); |
44 ++func_index; | 44 ++func_index; |
45 } | 45 } |
46 | 46 |
47 module.module_start = reinterpret_cast<byte *>(all_names.data()); | 47 module.module_start = reinterpret_cast<byte *>(all_names.data()); |
48 module.module_end = module.module_start + all_names.size(); | 48 module.module_end = module.module_start + all_names.size(); |
49 | 49 |
50 Handle<Object> wasm_function_name_table = | 50 Handle<Object> wasm_function_name_table = |
51 BuildFunctionNamesTable(isolate, &module); | 51 BuildFunctionNamesTable(isolate, &module); |
52 CHECK(wasm_function_name_table->IsByteArray()); | 52 CHECK(wasm_function_name_table->IsByteArray()); |
53 | 53 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 TEST(ThreeUnnamedFunctions) { | 102 TEST(ThreeUnnamedFunctions) { |
103 const char *names[] = {"", "", ""}; | 103 const char *names[] = {"", "", ""}; |
104 testFunctionNameTable(ArrayVector(names)); | 104 testFunctionNameTable(ArrayVector(names)); |
105 } | 105 } |
106 | 106 |
107 TEST(UTF8Names) { | 107 TEST(UTF8Names) { |
108 const char *names[] = {"↱fun↰", "↺", "alpha:α beta:β"}; | 108 const char *names[] = {"↱fun↰", "↺", "alpha:α beta:β"}; |
109 testFunctionNameTable(ArrayVector(names)); | 109 testFunctionNameTable(ArrayVector(names)); |
110 } | 110 } |
OLD | NEW |