[wasm] Remove 'using namespace' from wasm-objects.cc

This violated the style guide, and caused problems for jumbo builds.

R=titzer@chromium.org
CC=mostynb@opera.com

Bug: chromium:746958
Change-Id: Iaa75d444f5b5f595c54058de14b394119390921c
Reviewed-on: https://chromium-review.googlesource.com/645529
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47744}
This commit is contained in:
Clemens Hammacher 2017-08-31 14:24:58 +02:00 committed by Commit Bot
parent 510421d876
commit 4c19fa447f
2 changed files with 51 additions and 50 deletions

View File

@ -27,19 +27,13 @@
instance->PrintInstancesChain(); \
} while (false)
#if __clang__
// TODO(mostynb@opera.com): remove the using statements and these pragmas.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wheader-hygiene"
#endif
namespace v8 {
namespace internal {
using namespace v8::internal;
using namespace v8::internal::wasm;
#if __clang__
// TODO(mostynb@opera.com): remove the using statements and these pragmas.
#pragma clang diagnostic pop
#endif
// Import a few often used types from the wasm namespace.
using GlobalHandleAddress = wasm::GlobalHandleAddress;
using WasmFunction = wasm::WasmFunction;
using WasmModule = wasm::WasmModule;
namespace {
@ -152,11 +146,12 @@ bool IsBreakablePosition(Handle<WasmCompiledModule> compiled_module,
DisallowHeapAllocation no_gc;
AccountingAllocator alloc;
Zone tmp(&alloc, ZONE_NAME);
BodyLocalDecls locals(&tmp);
wasm::BodyLocalDecls locals(&tmp);
const byte* module_start = compiled_module->module_bytes()->GetChars();
WasmFunction& func = compiled_module->module()->functions[func_index];
BytecodeIterator iterator(module_start + func.code.offset(),
module_start + func.code.end_offset(), &locals);
wasm::BytecodeIterator iterator(module_start + func.code.offset(),
module_start + func.code.end_offset(),
&locals);
DCHECK_LT(0, locals.encoded_size);
for (uint32_t offset : iterator.offsets()) {
if (offset > static_cast<uint32_t>(offset_in_func)) break;
@ -281,7 +276,8 @@ void WasmTableObject::grow(Isolate* isolate, uint32_t count) {
// Patch the code of the respective instance.
{
DisallowHeapAllocation no_gc;
CodeSpecialization code_specialization(isolate, &specialization_zone);
wasm::CodeSpecialization code_specialization(isolate,
&specialization_zone);
WasmInstanceObject* instance =
WasmInstanceObject::cast(dispatch_tables->get(i));
WasmCompiledModule* compiled_module = instance->compiled_module();
@ -335,12 +331,12 @@ Handle<JSArrayBuffer> GrowMemoryBuffer(Isolate* isolate,
// TODO(gdeepti): Change the protection here instead of allocating a new
// buffer before guard regions are turned on, see issue #5886.
const bool enable_guard_regions = old_buffer.is_null()
? EnableGuardRegions()
? wasm::EnableGuardRegions()
: old_buffer->has_guard_region();
size_t new_size =
static_cast<size_t>(old_pages + pages) * WasmModule::kPageSize;
Handle<JSArrayBuffer> new_buffer =
NewArrayBuffer(isolate, new_size, enable_guard_regions);
wasm::NewArrayBuffer(isolate, new_size, enable_guard_regions);
if (new_buffer.is_null()) return new_buffer;
Address new_mem_start = static_cast<Address>(new_buffer->backing_store());
memcpy(new_mem_start, old_mem_start, old_size);
@ -367,7 +363,7 @@ void UncheckedUpdateInstanceMemory(Isolate* isolate,
Address new_mem_start = static_cast<Address>(mem_buffer->backing_store());
DCHECK_NOT_NULL(new_mem_start);
Zone specialization_zone(isolate->allocator(), ZONE_NAME);
CodeSpecialization code_specialization(isolate, &specialization_zone);
wasm::CodeSpecialization code_specialization(isolate, &specialization_zone);
code_specialization.RelocateMemoryReferences(old_mem_start, old_size,
new_mem_start, new_size);
code_specialization.ApplyToWholeInstance(*instance);
@ -383,9 +379,9 @@ Handle<WasmMemoryObject> WasmMemoryObject::New(Isolate* isolate,
auto memory_obj = Handle<WasmMemoryObject>::cast(
isolate->factory()->NewJSObject(memory_ctor, TENURED));
if (buffer.is_null()) {
const bool enable_guard_regions = EnableGuardRegions();
buffer = SetupArrayBuffer(isolate, nullptr, 0, nullptr, 0, false,
enable_guard_regions);
const bool enable_guard_regions = wasm::EnableGuardRegions();
buffer = wasm::SetupArrayBuffer(isolate, nullptr, 0, nullptr, 0, false,
enable_guard_regions);
}
memory_obj->set_array_buffer(*buffer);
memory_obj->set_maximum_pages(maximum);
@ -395,7 +391,7 @@ Handle<WasmMemoryObject> WasmMemoryObject::New(Isolate* isolate,
uint32_t WasmMemoryObject::current_pages() {
uint32_t byte_length;
CHECK(array_buffer()->byte_length()->ToUint32(&byte_length));
return byte_length / wasm::WasmModule::kPageSize;
return byte_length / WasmModule::kPageSize;
}
void WasmMemoryObject::AddInstance(Isolate* isolate,
@ -430,11 +426,11 @@ int32_t WasmMemoryObject::Grow(Isolate* isolate,
if (pages == 0) {
// Even for pages == 0, we need to attach a new JSArrayBuffer with the same
// backing store and neuter the old one to be spec compliant.
new_buffer = SetupArrayBuffer(
isolate, old_buffer->allocation_base(),
old_buffer->allocation_length(), old_buffer->backing_store(),
old_size, old_buffer->is_external(), old_buffer->has_guard_region());
memory_object->set_array_buffer(*new_buffer);
new_buffer = wasm::SetupArrayBuffer(
isolate, old_buffer->allocation_base(), old_buffer->allocation_length(),
old_buffer->backing_store(), old_size, old_buffer->is_external(),
old_buffer->has_guard_region());
memory_object->set_array_buffer(*new_buffer);
DCHECK_EQ(0, old_size % WasmModule::kPageSize);
return old_size / WasmModule::kPageSize;
}
@ -639,13 +635,13 @@ WasmSharedModuleData* WasmSharedModuleData::cast(Object* object) {
return reinterpret_cast<WasmSharedModuleData*>(object);
}
wasm::WasmModule* WasmSharedModuleData::module() {
WasmModule* WasmSharedModuleData::module() {
// We populate the kModuleWrapper field with a Foreign holding the
// address to the address of a WasmModule. This is because we can
// handle both cases when the WasmModule's lifetime is managed through
// a Managed<WasmModule> object, as well as cases when it's managed
// by the embedder. CcTests fall into the latter case.
return *(reinterpret_cast<wasm::WasmModule**>(
return *(reinterpret_cast<WasmModule**>(
Foreign::cast(get(kModuleWrapperIndex))->foreign_address()));
}
@ -702,8 +698,8 @@ void WasmSharedModuleData::ReinitializeAfterDeserialization(
const byte* end = start + module_bytes->length();
// TODO(titzer): remember the module origin in the compiled_module
// For now, we assume serialized modules did not originate from asm.js.
ModuleResult result =
SyncDecodeWasmModule(isolate, start, end, false, kWasmOrigin);
wasm::ModuleResult result =
SyncDecodeWasmModule(isolate, start, end, false, wasm::kWasmOrigin);
CHECK(result.ok());
CHECK_NOT_NULL(result.val);
// Take ownership of the WasmModule and immediately transfer it to the
@ -711,8 +707,8 @@ void WasmSharedModuleData::ReinitializeAfterDeserialization(
module = result.val.release();
}
Handle<WasmModuleWrapper> module_wrapper =
WasmModuleWrapper::New(isolate, module);
Handle<wasm::WasmModuleWrapper> module_wrapper =
wasm::WasmModuleWrapper::New(isolate, module);
shared->set(kModuleWrapperIndex, *module_wrapper);
DCHECK(WasmSharedModuleData::IsWasmSharedModuleData(*shared));
@ -842,17 +838,17 @@ void WasmSharedModuleData::PrepareForLazyCompilation(
Handle<WasmSharedModuleData> shared) {
if (shared->has_lazy_compilation_orchestrator()) return;
Isolate* isolate = shared->GetIsolate();
LazyCompilationOrchestrator* orch = new LazyCompilationOrchestrator();
Handle<Managed<LazyCompilationOrchestrator>> orch_handle =
Managed<LazyCompilationOrchestrator>::New(isolate, orch);
auto* orch = new wasm::LazyCompilationOrchestrator();
Handle<Managed<wasm::LazyCompilationOrchestrator>> orch_handle =
Managed<wasm::LazyCompilationOrchestrator>::New(isolate, orch);
shared->set_lazy_compilation_orchestrator(*orch_handle);
}
Handle<WasmCompiledModule> WasmCompiledModule::New(
Isolate* isolate, Handle<WasmSharedModuleData> shared,
Handle<FixedArray> code_table, Handle<FixedArray> export_wrappers,
const std::vector<wasm::GlobalHandleAddress>& function_tables,
const std::vector<wasm::GlobalHandleAddress>& signature_tables) {
const std::vector<GlobalHandleAddress>& function_tables,
const std::vector<GlobalHandleAddress>& signature_tables) {
DCHECK_EQ(function_tables.size(), signature_tables.size());
Handle<FixedArray> ret =
isolate->factory()->NewFixedArray(PropertyIndices::Count, TENURED);
@ -964,7 +960,7 @@ void WasmCompiledModule::Reset(Isolate* isolate,
// Patch code to update memory references, global references, and function
// table references.
Zone specialization_zone(isolate->allocator(), ZONE_NAME);
CodeSpecialization code_specialization(isolate, &specialization_zone);
wasm::CodeSpecialization code_specialization(isolate, &specialization_zone);
code_specialization.RelocateMemoryReferences(old_mem_start, old_mem_size,
nullptr, default_mem_size);
@ -1089,7 +1085,7 @@ void WasmCompiledModule::SetGlobalsStartAddressFrom(
MaybeHandle<String> WasmCompiledModule::ExtractUtf8StringFromModuleBytes(
Isolate* isolate, Handle<WasmCompiledModule> compiled_module,
WireBytesRef ref) {
wasm::WireBytesRef ref) {
// TODO(wasm): cache strings from modules if it's a performance win.
Handle<SeqOneByteString> module_bytes(compiled_module->module_bytes(),
isolate);
@ -1308,7 +1304,7 @@ Handle<ByteArray> GetDecodedAsmJsOffsetTable(
DCHECK(table_type == Encoded || table_type == Decoded);
if (table_type == Decoded) return offset_table;
AsmJsOffsetsResult asm_offsets;
wasm::AsmJsOffsetsResult asm_offsets;
{
DisallowHeapAllocation no_gc;
const byte* bytes_start = offset_table->GetDataStartAddress();
@ -1341,10 +1337,11 @@ Handle<ByteArray> GetDecodedAsmJsOffsetTable(
int idx = 0;
std::vector<WasmFunction>& wasm_funs = compiled_module->module()->functions;
for (int func = 0; func < num_functions; ++func) {
std::vector<AsmJsOffsetEntry>& func_asm_offsets = asm_offsets.val[func];
std::vector<wasm::AsmJsOffsetEntry>& func_asm_offsets =
asm_offsets.val[func];
if (func_asm_offsets.empty()) continue;
int func_offset = wasm_funs[num_imported_functions + func].code.offset();
for (AsmJsOffsetEntry& e : func_asm_offsets) {
for (wasm::AsmJsOffsetEntry& e : func_asm_offsets) {
// Byte offsets must be strictly monotonously increasing:
DCHECK_IMPLIES(idx > 0, func_offset + e.byte_offset >
decoded_table->get_int(idx - kOTESize));
@ -1477,9 +1474,10 @@ bool WasmCompiledModule::GetPossibleBreakpoints(
WasmFunction& func = functions[func_idx];
if (func.code.length() == 0) continue;
BodyLocalDecls locals(&tmp);
BytecodeIterator iterator(module_start + func.code.offset(),
module_start + func.code.end_offset(), &locals);
wasm::BodyLocalDecls locals(&tmp);
wasm::BytecodeIterator iterator(module_start + func.code.offset(),
module_start + func.code.end_offset(),
&locals);
DCHECK_LT(0u, locals.encoded_size);
for (uint32_t offset : iterator.offsets()) {
uint32_t total_offset = func.code.offset() + offset;
@ -1552,8 +1550,11 @@ Handle<Code> WasmCompiledModule::CompileLazy(
isolate->set_context(*instance->compiled_module()->native_context());
Object* orch_obj =
instance->compiled_module()->shared()->lazy_compilation_orchestrator();
LazyCompilationOrchestrator* orch =
Managed<LazyCompilationOrchestrator>::cast(orch_obj)->get();
auto* orch =
Managed<wasm::LazyCompilationOrchestrator>::cast(orch_obj)->get();
return orch->CompileLazy(isolate, instance, caller, offset, func_index,
patch_caller);
}
} // namespace internal
} // namespace v8

View File

@ -27,7 +27,7 @@ class WasmInterpreter;
// When we compile or instantiate, we need to create global handles
// for function tables. Normally, these handles get destroyed when the
// respective objects get GCed. If we fail to construct those objects,
// we can leak global hanles. The exit path in these cases isn't unique,
// we can leak global handles. The exit path in these cases isn't unique,
// and may grow.
//
// This type addresses that.