| 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 | 6 |
| 7 #include "src/wasm/wasm-module.h" | 7 #include "src/wasm/wasm-module.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 auto undefined = [&func_names_array]() -> Handle<Object> { | 53 auto undefined = [&func_names_array]() -> Handle<Object> { |
| 54 return func_names_array->GetIsolate()->factory()->undefined_value(); | 54 return func_names_array->GetIsolate()->factory()->undefined_value(); |
| 55 }; | 55 }; |
| 56 if (func_index >= num_funcs) return undefined(); | 56 if (func_index >= num_funcs) return undefined(); |
| 57 int offset = func_names_array->get_int(func_index + 1); | 57 int offset = func_names_array->get_int(func_index + 1); |
| 58 int next_offset = func_index == num_funcs - 1 | 58 int next_offset = func_index == num_funcs - 1 |
| 59 ? func_names_array->length() | 59 ? func_names_array->length() |
| 60 : func_names_array->get_int(func_index + 2); | 60 : func_names_array->get_int(func_index + 2); |
| 61 ScopedVector<byte> buffer(next_offset - offset); | 61 ScopedVector<byte> buffer(next_offset - offset); |
| 62 func_names_array->copy_out(offset, buffer.start(), next_offset - offset); | 62 func_names_array->copy_out(offset, buffer.start(), next_offset - offset); |
| 63 if (!unibrow::Utf8::Validate(buffer.start(), buffer.length())) { |
| 64 return undefined(); |
| 65 } |
| 63 MaybeHandle<Object> maybe_name = | 66 MaybeHandle<Object> maybe_name = |
| 64 func_names_array->GetIsolate()->factory()->NewStringFromUtf8( | 67 func_names_array->GetIsolate()->factory()->NewStringFromUtf8( |
| 65 Vector<const char>::cast(buffer)); | 68 Vector<const char>::cast(buffer)); |
| 66 return maybe_name.is_null() ? undefined() : maybe_name.ToHandleChecked(); | 69 return maybe_name.is_null() ? undefined() : maybe_name.ToHandleChecked(); |
| 67 } | 70 } |
| 68 | 71 |
| 69 } // namespace wasm | 72 } // namespace wasm |
| 70 } // namespace internal | 73 } // namespace internal |
| 71 } // namespace v8 | 74 } // namespace v8 |
| OLD | NEW |