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

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

Issue 2526783002: [base] Define CHECK comparison for signed vs. unsigned (Closed)
Patch Set: Rebase Created 4 years 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 | « src/wasm/wasm-module.h ('k') | src/wasm/wasm-objects.cc » ('j') | 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 <memory> 5 #include <memory>
6 6
7 #include "src/base/atomic-utils.h" 7 #include "src/base/atomic-utils.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 9
10 #include "src/macro-assembler.h" 10 #include "src/macro-assembler.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 byte* raw_buffer_ptr(MaybeHandle<JSArrayBuffer> buffer, int offset) { 46 byte* raw_buffer_ptr(MaybeHandle<JSArrayBuffer> buffer, int offset) {
47 return static_cast<byte*>(buffer.ToHandleChecked()->backing_store()) + offset; 47 return static_cast<byte*>(buffer.ToHandleChecked()->backing_store()) + offset;
48 } 48 }
49 49
50 MaybeHandle<String> ExtractStringFromModuleBytes( 50 MaybeHandle<String> ExtractStringFromModuleBytes(
51 Isolate* isolate, Handle<WasmCompiledModule> compiled_module, 51 Isolate* isolate, Handle<WasmCompiledModule> compiled_module,
52 uint32_t offset, uint32_t size) { 52 uint32_t offset, uint32_t size) {
53 // TODO(wasm): cache strings from modules if it's a performance win. 53 // TODO(wasm): cache strings from modules if it's a performance win.
54 Handle<SeqOneByteString> module_bytes = compiled_module->module_bytes(); 54 Handle<SeqOneByteString> module_bytes = compiled_module->module_bytes();
55 DCHECK_GE(static_cast<size_t>(module_bytes->length()), offset); 55 DCHECK_GE(module_bytes->length(), offset);
56 DCHECK_GE(static_cast<size_t>(module_bytes->length() - offset), size); 56 DCHECK_GE(module_bytes->length() - offset, size);
57 Address raw = module_bytes->GetCharsAddress() + offset; 57 Address raw = module_bytes->GetCharsAddress() + offset;
58 if (!unibrow::Utf8::Validate(reinterpret_cast<const byte*>(raw), size)) 58 if (!unibrow::Utf8::Validate(reinterpret_cast<const byte*>(raw), size))
59 return {}; // UTF8 decoding error for name. 59 return {}; // UTF8 decoding error for name.
60 return isolate->factory()->NewStringFromUtf8SubString( 60 return isolate->factory()->NewStringFromUtf8SubString(
61 module_bytes, static_cast<int>(offset), static_cast<int>(size)); 61 module_bytes, static_cast<int>(offset), static_cast<int>(size));
62 } 62 }
63 63
64 void ReplaceReferenceInCode(Handle<Code> code, Handle<Object> old_ref, 64 void ReplaceReferenceInCode(Handle<Code> code, Handle<Object> old_ref,
65 Handle<Object> new_ref) { 65 Handle<Object> new_ref) {
66 for (RelocIterator it(*code, 1 << RelocInfo::EMBEDDED_OBJECT); !it.done(); 66 for (RelocIterator it(*code, 1 << RelocInfo::EMBEDDED_OBJECT); !it.done();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // things that would be unsafe if they expected guard pages where there 104 // things that would be unsafe if they expected guard pages where there
105 // weren't any. 105 // weren't any.
106 if (enable_guard_regions && kGuardRegionsSupported) { 106 if (enable_guard_regions && kGuardRegionsSupported) {
107 // TODO(eholk): On Windows we want to make sure we don't commit the guard 107 // TODO(eholk): On Windows we want to make sure we don't commit the guard
108 // pages yet. 108 // pages yet.
109 109
110 // We always allocate the largest possible offset into the heap, so the 110 // We always allocate the largest possible offset into the heap, so the
111 // addressable memory after the guard page can be made inaccessible. 111 // addressable memory after the guard page can be made inaccessible.
112 const size_t alloc_size = 112 const size_t alloc_size =
113 RoundUp(kWasmMaxHeapOffset, base::OS::CommitPageSize()); 113 RoundUp(kWasmMaxHeapOffset, base::OS::CommitPageSize());
114 DCHECK_EQ(0u, size % base::OS::CommitPageSize()); 114 DCHECK_EQ(0, size % base::OS::CommitPageSize());
115 115
116 // AllocateGuarded makes the whole region inaccessible by default. 116 // AllocateGuarded makes the whole region inaccessible by default.
117 void* memory = base::OS::AllocateGuarded(alloc_size); 117 void* memory = base::OS::AllocateGuarded(alloc_size);
118 if (memory == nullptr) { 118 if (memory == nullptr) {
119 return nullptr; 119 return nullptr;
120 } 120 }
121 121
122 // Make the part we care about accessible. 122 // Make the part we care about accessible.
123 base::OS::Unprotect(memory, size); 123 base::OS::Unprotect(memory, size);
124 124
(...skipping 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after
2067 2067
2068 DCHECK_EQ(origin == kAsmJsOrigin, !asm_js_script.is_null()); 2068 DCHECK_EQ(origin == kAsmJsOrigin, !asm_js_script.is_null());
2069 DCHECK(!compiled_module->has_script()); 2069 DCHECK(!compiled_module->has_script());
2070 DCHECK(!compiled_module->has_asm_js_offset_table()); 2070 DCHECK(!compiled_module->has_asm_js_offset_table());
2071 if (origin == kAsmJsOrigin) { 2071 if (origin == kAsmJsOrigin) {
2072 // Set script for the asm.js source, and the offset table mapping wasm byte 2072 // Set script for the asm.js source, and the offset table mapping wasm byte
2073 // offsets to source positions. 2073 // offsets to source positions.
2074 compiled_module->set_script(asm_js_script); 2074 compiled_module->set_script(asm_js_script);
2075 size_t offset_table_len = 2075 size_t offset_table_len =
2076 asm_js_offset_tables_end - asm_js_offset_tables_start; 2076 asm_js_offset_tables_end - asm_js_offset_tables_start;
2077 DCHECK_GE(static_cast<size_t>(kMaxInt), offset_table_len); 2077 DCHECK_GE(kMaxInt, offset_table_len);
2078 Handle<ByteArray> offset_table = 2078 Handle<ByteArray> offset_table =
2079 isolate->factory()->NewByteArray(static_cast<int>(offset_table_len)); 2079 isolate->factory()->NewByteArray(static_cast<int>(offset_table_len));
2080 memcpy(offset_table->GetDataStartAddress(), asm_js_offset_tables_start, 2080 memcpy(offset_table->GetDataStartAddress(), asm_js_offset_tables_start,
2081 offset_table_len); 2081 offset_table_len);
2082 compiled_module->set_asm_js_offset_table(offset_table); 2082 compiled_module->set_asm_js_offset_table(offset_table);
2083 } else { 2083 } else {
2084 // Create a new Script object representing this wasm module, store it in the 2084 // Create a new Script object representing this wasm module, store it in the
2085 // compiled wasm module, and register it at the debugger. 2085 // compiled wasm module, and register it at the debugger.
2086 Handle<Script> script = 2086 Handle<Script> script =
2087 isolate->factory()->NewScript(isolate->factory()->empty_string()); 2087 isolate->factory()->NewScript(isolate->factory()->empty_string());
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2383 MaybeHandle<String> WasmCompiledModule::GetFunctionName( 2383 MaybeHandle<String> WasmCompiledModule::GetFunctionName(
2384 Handle<WasmCompiledModule> compiled_module, uint32_t func_index) { 2384 Handle<WasmCompiledModule> compiled_module, uint32_t func_index) {
2385 DCHECK_LT(func_index, compiled_module->module()->functions.size()); 2385 DCHECK_LT(func_index, compiled_module->module()->functions.size());
2386 WasmFunction& function = compiled_module->module()->functions[func_index]; 2386 WasmFunction& function = compiled_module->module()->functions[func_index];
2387 Isolate* isolate = compiled_module->GetIsolate(); 2387 Isolate* isolate = compiled_module->GetIsolate();
2388 MaybeHandle<String> string = ExtractStringFromModuleBytes( 2388 MaybeHandle<String> string = ExtractStringFromModuleBytes(
2389 isolate, compiled_module, function.name_offset, function.name_length); 2389 isolate, compiled_module, function.name_offset, function.name_length);
2390 if (!string.is_null()) return string.ToHandleChecked(); 2390 if (!string.is_null()) return string.ToHandleChecked();
2391 return {}; 2391 return {};
2392 } 2392 }
OLDNEW
« no previous file with comments | « src/wasm/wasm-module.h ('k') | src/wasm/wasm-objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698