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

Side by Side Diff: src/wasm/wasm-module.cc

Issue 2105293002: [wasm] Do not used "undefined" for function signature padding. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/base/atomic-utils.h" 5 #include "src/base/atomic-utils.h"
6 #include "src/macro-assembler.h" 6 #include "src/macro-assembler.h"
7 #include "src/objects.h" 7 #include "src/objects.h"
8 #include "src/property-descriptor.h" 8 #include "src/property-descriptor.h"
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 238 }
239 239
240 Handle<FixedArray> fixed = isolate->factory()->NewFixedArray(2 * table_size); 240 Handle<FixedArray> fixed = isolate->factory()->NewFixedArray(2 * table_size);
241 for (uint32_t i = 0; 241 for (uint32_t i = 0;
242 i < static_cast<uint32_t>(module->function_table.size()); 242 i < static_cast<uint32_t>(module->function_table.size());
243 ++i) { 243 ++i) {
244 const WasmFunction* function = 244 const WasmFunction* function =
245 &module->functions[module->function_table[i]]; 245 &module->functions[module->function_table[i]];
246 fixed->set(i, Smi::FromInt(function->sig_index)); 246 fixed->set(i, Smi::FromInt(function->sig_index));
247 } 247 }
248 // Set the remaining elements to -1 (instead of "undefined"). These
249 // elements are accessed directly as SMIs (without a check). On 64-bit
250 // platforms, it is possible to have the top bits of "undefined" take
251 // small integer values (or zero), which are more likely to be equal to
252 // the signature index we check against.
253 for (uint32_t i = static_cast<uint32_t>(module->function_table.size());
254 i < table_size;
255 ++i) {
256 fixed->set(i, Smi::FromInt(-1));
257 }
248 return fixed; 258 return fixed;
249 } 259 }
250 260
251 Handle<JSArrayBuffer> NewArrayBuffer(Isolate* isolate, size_t size) { 261 Handle<JSArrayBuffer> NewArrayBuffer(Isolate* isolate, size_t size) {
252 if (size > (WasmModule::kMaxMemPages * WasmModule::kPageSize)) { 262 if (size > (WasmModule::kMaxMemPages * WasmModule::kPageSize)) {
253 // TODO(titzer): lift restriction on maximum memory allocated here. 263 // TODO(titzer): lift restriction on maximum memory allocated here.
254 return Handle<JSArrayBuffer>::null(); 264 return Handle<JSArrayBuffer>::null();
255 } 265 }
256 void* memory = isolate->array_buffer_allocator()->Allocate(size); 266 void* memory = isolate->array_buffer_allocator()->Allocate(size);
257 if (memory == nullptr) { 267 if (memory == nullptr) {
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); 1384 return static_cast<int32_t>(HeapNumber::cast(*result)->value());
1375 } 1385 }
1376 thrower.Error("WASM.compileRun() failed: Return value should be number"); 1386 thrower.Error("WASM.compileRun() failed: Return value should be number");
1377 return -1; 1387 return -1;
1378 } 1388 }
1379 1389
1380 } // namespace testing 1390 } // namespace testing
1381 } // namespace wasm 1391 } // namespace wasm
1382 } // namespace internal 1392 } // namespace internal
1383 } // namespace v8 1393 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698