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

Unified Diff: src/wasm/wasm-function-name-table.cc

Issue 2057523002: [wasm] Refactor function name table and lookup (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix gc issue Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-function-name-table.h ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-function-name-table.cc
diff --git a/src/wasm/wasm-function-name-table.cc b/src/wasm/wasm-function-name-table.cc
index 60ea977f890eee78789f01f99db2a587e6288aaf..cc52125500b9ed2b04e54249afd9546e6fd623f6 100644
--- a/src/wasm/wasm-function-name-table.cc
+++ b/src/wasm/wasm-function-name-table.cc
@@ -18,23 +18,19 @@ namespace wasm {
// integer entry is the negative offset of the next function name.
// After these N+1 integer entries, the second part begins, which holds a
// concatenation of all function names.
-//
-// Returns undefined if the array length would not fit in an integer value.
-Handle<Object> BuildFunctionNamesTable(Isolate* isolate,
- const WasmModule* module) {
+Handle<ByteArray> BuildFunctionNamesTable(Isolate* isolate,
+ const WasmModule* module) {
uint64_t func_names_length = 0;
for (auto& func : module->functions) func_names_length += func.name_length;
int num_funcs_int = static_cast<int>(module->functions.size());
int current_offset = (num_funcs_int + 1) * kIntSize;
uint64_t total_array_length = current_offset + func_names_length;
int total_array_length_int = static_cast<int>(total_array_length);
- // Check for overflow. Just skip function names if it happens.
- if (total_array_length_int != total_array_length || num_funcs_int < 0 ||
- num_funcs_int != module->functions.size())
- return isolate->factory()->undefined_value();
+ // Check for overflow.
+ CHECK(total_array_length_int == total_array_length && num_funcs_int >= 0 &&
+ num_funcs_int == module->functions.size());
Handle<ByteArray> func_names_array =
isolate->factory()->NewByteArray(total_array_length_int, TENURED);
- if (func_names_array.is_null()) return isolate->factory()->undefined_value();
func_names_array->set_int(0, num_funcs_int);
int func_index = 0;
for (const WasmFunction& fun : module->functions) {
« no previous file with comments | « src/wasm/wasm-function-name-table.h ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698