Commit 510421d8 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Remove all 'using namespace' declarations

They violate the style guide, and cause problems for jumbo builds.
This CL removes all occurrences in src/wasm except for the file
wasm-objects.cc, which is a bit more involved and will be fixed in a
separate CL.

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

Bug: chromium:746958
Change-Id: If5d9c03e0d6fa364e1d21feda49773468a48fba6
Reviewed-on: https://chromium-review.googlesource.com/645707
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47743}
parent 28346b1f
...@@ -67,22 +67,22 @@ V8_BASE_EXPORT void SetPrintStackTrace(void (*print_stack_trace_)()); ...@@ -67,22 +67,22 @@ V8_BASE_EXPORT void SetPrintStackTrace(void (*print_stack_trace_)());
// Helper macro for binary operators. // Helper macro for binary operators.
// Don't use this macro directly in your code, use CHECK_EQ et al below. // Don't use this macro directly in your code, use CHECK_EQ et al below.
#define CHECK_OP(name, op, lhs, rhs) \ #define CHECK_OP(name, op, lhs, rhs) \
do { \ do { \
if (std::string* _msg = ::v8::base::Check##name##Impl< \ if (std::string* _msg = ::v8::base::Check##name##Impl< \
typename v8::base::pass_value_or_ref<decltype(lhs)>::type, \ typename ::v8::base::pass_value_or_ref<decltype(lhs)>::type, \
typename v8::base::pass_value_or_ref<decltype(rhs)>::type>( \ typename ::v8::base::pass_value_or_ref<decltype(rhs)>::type>( \
(lhs), (rhs), #lhs " " #op " " #rhs)) { \ (lhs), (rhs), #lhs " " #op " " #rhs)) { \
V8_Fatal(__FILE__, __LINE__, "Check failed: %s.", _msg->c_str()); \ V8_Fatal(__FILE__, __LINE__, "Check failed: %s.", _msg->c_str()); \
delete _msg; \ delete _msg; \
} \ } \
} while (0) } while (0)
#define DCHECK_OP(name, op, lhs, rhs) \ #define DCHECK_OP(name, op, lhs, rhs) \
do { \ do { \
if (std::string* _msg = ::v8::base::Check##name##Impl< \ if (std::string* _msg = ::v8::base::Check##name##Impl< \
typename v8::base::pass_value_or_ref<decltype(lhs)>::type, \ typename ::v8::base::pass_value_or_ref<decltype(lhs)>::type, \
typename v8::base::pass_value_or_ref<decltype(rhs)>::type>( \ typename ::v8::base::pass_value_or_ref<decltype(rhs)>::type>( \
(lhs), (rhs), #lhs " " #op " " #rhs)) { \ (lhs), (rhs), #lhs " " #op " " #rhs)) { \
V8_Fatal(__FILE__, __LINE__, "Debug check failed: %s.", _msg->c_str()); \ V8_Fatal(__FILE__, __LINE__, "Debug check failed: %s.", _msg->c_str()); \
delete _msg; \ delete _msg; \
...@@ -94,13 +94,13 @@ V8_BASE_EXPORT void SetPrintStackTrace(void (*print_stack_trace_)()); ...@@ -94,13 +94,13 @@ V8_BASE_EXPORT void SetPrintStackTrace(void (*print_stack_trace_)());
// Make all CHECK functions discard their log strings to reduce code // Make all CHECK functions discard their log strings to reduce code
// bloat for official release builds. // bloat for official release builds.
#define CHECK_OP(name, op, lhs, rhs) \ #define CHECK_OP(name, op, lhs, rhs) \
do { \ do { \
bool _cmp = ::v8::base::Cmp##name##Impl< \ bool _cmp = ::v8::base::Cmp##name##Impl< \
typename v8::base::pass_value_or_ref<decltype(lhs)>::type, \ typename ::v8::base::pass_value_or_ref<decltype(lhs)>::type, \
typename v8::base::pass_value_or_ref<decltype(rhs)>::type>((lhs), \ typename ::v8::base::pass_value_or_ref<decltype(rhs)>::type>((lhs), \
(rhs)); \ (rhs)); \
CHECK_WITH_MSG(_cmp, #lhs " " #op " " #rhs); \ CHECK_WITH_MSG(_cmp, #lhs " " #op " " #rhs); \
} while (0) } while (0)
#define DCHECK_WITH_MSG(condition, msg) void(0); #define DCHECK_WITH_MSG(condition, msg) void(0);
......
...@@ -6,19 +6,9 @@ ...@@ -6,19 +6,9 @@
#include "src/wasm/leb-helper.h" #include "src/wasm/leb-helper.h"
#if __clang__ namespace v8 {
// TODO(mostynb@opera.com): remove the using statements and these pragmas. namespace internal {
#pragma clang diagnostic push namespace wasm {
#pragma clang diagnostic ignored "-Wheader-hygiene"
#endif
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
void LocalDeclEncoder::Prepend(Zone* zone, const byte** start, void LocalDeclEncoder::Prepend(Zone* zone, const byte** start,
const byte** end) const { const byte** end) const {
...@@ -60,3 +50,7 @@ size_t LocalDeclEncoder::Size() const { ...@@ -60,3 +50,7 @@ size_t LocalDeclEncoder::Size() const {
for (auto p : local_decls) size += 1 + LEBHelper::sizeof_u32v(p.first); for (auto p : local_decls) size += 1 + LEBHelper::sizeof_u32v(p.first);
return size; return size;
} }
} // namespace wasm
} // namespace internal
} // namespace v8
...@@ -15,19 +15,9 @@ ...@@ -15,19 +15,9 @@
#include "src/wasm/wasm-objects.h" #include "src/wasm/wasm-objects.h"
#include "src/wasm/wasm-result.h" #include "src/wasm/wasm-result.h"
#if __clang__ namespace v8 {
// TODO(mostynb@opera.com): remove the using statements and these pragmas. namespace internal {
#pragma clang diagnostic push namespace wasm {
#pragma clang diagnostic ignored "-Wheader-hygiene"
#endif
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
void StreamingDecoder::OnBytesReceived(Vector<const uint8_t> bytes) { void StreamingDecoder::OnBytesReceived(Vector<const uint8_t> bytes) {
size_t current = 0; size_t current = 0;
...@@ -387,3 +377,7 @@ StreamingDecoder::StreamingDecoder(Isolate* isolate) ...@@ -387,3 +377,7 @@ StreamingDecoder::StreamingDecoder(Isolate* isolate)
decoder_(nullptr, nullptr) { decoder_(nullptr, nullptr) {
USE(isolate_); USE(isolate_);
} }
} // namespace wasm
} // namespace internal
} // namespace v8
...@@ -12,18 +12,6 @@ ...@@ -12,18 +12,6 @@
#include "src/wasm/wasm-objects-inl.h" #include "src/wasm/wasm-objects-inl.h"
#include "src/wasm/wasm-opcodes.h" #include "src/wasm/wasm-opcodes.h"
#if __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wheader-hygiene"
#endif
using namespace v8::internal;
using namespace v8::internal::wasm;
#if __clang__
#pragma clang diagnostic pop
#endif
namespace v8 { namespace v8 {
namespace internal { namespace internal {
namespace wasm { namespace wasm {
...@@ -37,10 +25,6 @@ int ExtractDirectCallIndex(wasm::Decoder& decoder, const byte* pc) { ...@@ -37,10 +25,6 @@ int ExtractDirectCallIndex(wasm::Decoder& decoder, const byte* pc) {
return static_cast<int>(call_idx); return static_cast<int>(call_idx);
} }
} // namespace wasm
} // namespace internal
} // namespace v8
namespace { namespace {
int AdvanceSourcePositionTableIterator(SourcePositionTableIterator& iterator, int AdvanceSourcePositionTableIterator(SourcePositionTableIterator& iterator,
...@@ -282,3 +266,7 @@ bool CodeSpecialization::ApplyToWasmCode(Code* code, ...@@ -282,3 +266,7 @@ bool CodeSpecialization::ApplyToWasmCode(Code* code,
return changed; return changed;
} }
} // namespace wasm
} // namespace internal
} // namespace v8
...@@ -20,17 +20,9 @@ ...@@ -20,17 +20,9 @@
#include "src/wasm/wasm-objects-inl.h" #include "src/wasm/wasm-objects-inl.h"
#include "src/zone/accounting-allocator.h" #include "src/zone/accounting-allocator.h"
#if __clang__ namespace v8 {
#pragma clang diagnostic push namespace internal {
#pragma clang diagnostic ignored "-Wheader-hygiene" namespace wasm {
#endif
using namespace v8::internal;
using namespace v8::internal::wasm;
#if __clang__
#pragma clang diagnostic pop
#endif
namespace { namespace {
...@@ -98,10 +90,6 @@ MaybeHandle<String> GetLocalName(Isolate* isolate, ...@@ -98,10 +90,6 @@ MaybeHandle<String> GetLocalName(Isolate* isolate,
return handle(String::cast(func_locals_names->get(local_index))); return handle(String::cast(func_locals_names->get(local_index)));
} }
// Forward declaration.
class InterpreterHandle;
InterpreterHandle* GetInterpreterHandle(WasmDebugInfo* debug_info);
class InterpreterHandle { class InterpreterHandle {
MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(InterpreterHandle); MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(InterpreterHandle);
Isolate* isolate_; Isolate* isolate_;
...@@ -326,7 +314,12 @@ class InterpreterHandle { ...@@ -326,7 +314,12 @@ class InterpreterHandle {
WasmInterpreterEntryFrame* frame = WasmInterpreterEntryFrame* frame =
WasmInterpreterEntryFrame::cast(it.frame()); WasmInterpreterEntryFrame::cast(it.frame());
Handle<WasmInstanceObject> instance_obj(frame->wasm_instance(), isolate_); Handle<WasmInstanceObject> instance_obj(frame->wasm_instance(), isolate_);
DCHECK_EQ(this, GetInterpreterHandle(instance_obj->debug_info())); // Check that this is indeed the instance which is connected to this
// interpreter.
DCHECK_EQ(this, Managed<wasm::InterpreterHandle>::cast(
instance_obj->debug_info()->get(
WasmDebugInfo::kInterpreterHandleIndex))
->get());
return instance_obj; return instance_obj;
} }
...@@ -565,29 +558,35 @@ class InterpreterHandle { ...@@ -565,29 +558,35 @@ class InterpreterHandle {
} }
}; };
InterpreterHandle* GetOrCreateInterpreterHandle( } // namespace
} // namespace wasm
namespace {
wasm::InterpreterHandle* GetOrCreateInterpreterHandle(
Isolate* isolate, Handle<WasmDebugInfo> debug_info) { Isolate* isolate, Handle<WasmDebugInfo> debug_info) {
Handle<Object> handle(debug_info->get(WasmDebugInfo::kInterpreterHandleIndex), Handle<Object> handle(debug_info->get(WasmDebugInfo::kInterpreterHandleIndex),
isolate); isolate);
if (handle->IsUndefined(isolate)) { if (handle->IsUndefined(isolate)) {
InterpreterHandle* cpp_handle = new InterpreterHandle(isolate, *debug_info); auto* cpp_handle = new wasm::InterpreterHandle(isolate, *debug_info);
handle = Managed<InterpreterHandle>::New(isolate, cpp_handle); handle = Managed<wasm::InterpreterHandle>::New(isolate, cpp_handle);
debug_info->set(WasmDebugInfo::kInterpreterHandleIndex, *handle); debug_info->set(WasmDebugInfo::kInterpreterHandleIndex, *handle);
} }
return Handle<Managed<InterpreterHandle>>::cast(handle)->get(); return Handle<Managed<wasm::InterpreterHandle>>::cast(handle)->get();
} }
InterpreterHandle* GetInterpreterHandle(WasmDebugInfo* debug_info) { wasm::InterpreterHandle* GetInterpreterHandle(WasmDebugInfo* debug_info) {
Object* handle_obj = debug_info->get(WasmDebugInfo::kInterpreterHandleIndex); Object* handle_obj = debug_info->get(WasmDebugInfo::kInterpreterHandleIndex);
DCHECK(!handle_obj->IsUndefined(debug_info->GetIsolate())); DCHECK(!handle_obj->IsUndefined(debug_info->GetIsolate()));
return Managed<InterpreterHandle>::cast(handle_obj)->get(); return Managed<wasm::InterpreterHandle>::cast(handle_obj)->get();
} }
InterpreterHandle* GetInterpreterHandleOrNull(WasmDebugInfo* debug_info) { wasm::InterpreterHandle* GetInterpreterHandleOrNull(WasmDebugInfo* debug_info) {
Object* handle_obj = debug_info->get(WasmDebugInfo::kInterpreterHandleIndex); Object* handle_obj = debug_info->get(WasmDebugInfo::kInterpreterHandleIndex);
if (handle_obj->IsUndefined(debug_info->GetIsolate())) return nullptr; if (handle_obj->IsUndefined(debug_info->GetIsolate())) return nullptr;
return Managed<InterpreterHandle>::cast(handle_obj)->get(); return Managed<wasm::InterpreterHandle>::cast(handle_obj)->get();
} }
int GetNumFunctions(WasmInstanceObject* instance) { int GetNumFunctions(WasmInstanceObject* instance) {
...@@ -657,12 +656,13 @@ Handle<WasmDebugInfo> WasmDebugInfo::New(Handle<WasmInstanceObject> instance) { ...@@ -657,12 +656,13 @@ Handle<WasmDebugInfo> WasmDebugInfo::New(Handle<WasmInstanceObject> instance) {
return debug_info; return debug_info;
} }
WasmInterpreter* WasmDebugInfo::SetupForTesting( wasm::WasmInterpreter* WasmDebugInfo::SetupForTesting(
Handle<WasmInstanceObject> instance_obj) { Handle<WasmInstanceObject> instance_obj) {
Handle<WasmDebugInfo> debug_info = WasmDebugInfo::New(instance_obj); Handle<WasmDebugInfo> debug_info = WasmDebugInfo::New(instance_obj);
Isolate* isolate = instance_obj->GetIsolate(); Isolate* isolate = instance_obj->GetIsolate();
InterpreterHandle* cpp_handle = new InterpreterHandle(isolate, *debug_info); auto* cpp_handle = new wasm::InterpreterHandle(isolate, *debug_info);
Handle<Object> handle = Managed<InterpreterHandle>::New(isolate, cpp_handle); Handle<Object> handle =
Managed<wasm::InterpreterHandle>::New(isolate, cpp_handle);
debug_info->set(kInterpreterHandleIndex, *handle); debug_info->set(kInterpreterHandleIndex, *handle);
return cpp_handle->interpreter(); return cpp_handle->interpreter();
} }
...@@ -691,9 +691,9 @@ WasmInstanceObject* WasmDebugInfo::wasm_instance() { ...@@ -691,9 +691,9 @@ WasmInstanceObject* WasmDebugInfo::wasm_instance() {
void WasmDebugInfo::SetBreakpoint(Handle<WasmDebugInfo> debug_info, void WasmDebugInfo::SetBreakpoint(Handle<WasmDebugInfo> debug_info,
int func_index, int offset) { int func_index, int offset) {
Isolate* isolate = debug_info->GetIsolate(); Isolate* isolate = debug_info->GetIsolate();
InterpreterHandle* handle = GetOrCreateInterpreterHandle(isolate, debug_info); auto* handle = GetOrCreateInterpreterHandle(isolate, debug_info);
RedirectToInterpreter(debug_info, Vector<int>(&func_index, 1)); RedirectToInterpreter(debug_info, Vector<int>(&func_index, 1));
const WasmFunction* func = &handle->module()->functions[func_index]; const wasm::WasmFunction* func = &handle->module()->functions[func_index];
handle->interpreter()->SetBreakpoint(func, offset, true); handle->interpreter()->SetBreakpoint(func, offset, true);
} }
...@@ -753,12 +753,12 @@ void WasmDebugInfo::Unwind(Address frame_pointer) { ...@@ -753,12 +753,12 @@ void WasmDebugInfo::Unwind(Address frame_pointer) {
} }
uint64_t WasmDebugInfo::NumInterpretedCalls() { uint64_t WasmDebugInfo::NumInterpretedCalls() {
auto handle = GetInterpreterHandleOrNull(this); auto* handle = GetInterpreterHandleOrNull(this);
return handle ? handle->NumInterpretedCalls() : 0; return handle ? handle->NumInterpretedCalls() : 0;
} }
void WasmDebugInfo::UpdateMemory(JSArrayBuffer* new_memory) { void WasmDebugInfo::UpdateMemory(JSArrayBuffer* new_memory) {
InterpreterHandle* interp_handle = GetInterpreterHandleOrNull(this); auto* interp_handle = GetInterpreterHandleOrNull(this);
if (!interp_handle) return; if (!interp_handle) return;
interp_handle->UpdateMemory(new_memory); interp_handle->UpdateMemory(new_memory);
} }
...@@ -766,14 +766,14 @@ void WasmDebugInfo::UpdateMemory(JSArrayBuffer* new_memory) { ...@@ -766,14 +766,14 @@ void WasmDebugInfo::UpdateMemory(JSArrayBuffer* new_memory) {
// static // static
Handle<JSObject> WasmDebugInfo::GetScopeDetails( Handle<JSObject> WasmDebugInfo::GetScopeDetails(
Handle<WasmDebugInfo> debug_info, Address frame_pointer, int frame_index) { Handle<WasmDebugInfo> debug_info, Address frame_pointer, int frame_index) {
InterpreterHandle* interp_handle = GetInterpreterHandle(*debug_info); auto* interp_handle = GetInterpreterHandle(*debug_info);
return interp_handle->GetScopeDetails(frame_pointer, frame_index, debug_info); return interp_handle->GetScopeDetails(frame_pointer, frame_index, debug_info);
} }
// static // static
Handle<JSObject> WasmDebugInfo::GetGlobalScopeObject( Handle<JSObject> WasmDebugInfo::GetGlobalScopeObject(
Handle<WasmDebugInfo> debug_info, Address frame_pointer, int frame_index) { Handle<WasmDebugInfo> debug_info, Address frame_pointer, int frame_index) {
InterpreterHandle* interp_handle = GetInterpreterHandle(*debug_info); auto* interp_handle = GetInterpreterHandle(*debug_info);
auto frame = interp_handle->GetInterpretedFrame(frame_pointer, frame_index); auto frame = interp_handle->GetInterpretedFrame(frame_pointer, frame_index);
return interp_handle->GetGlobalScopeObject(frame.get(), debug_info); return interp_handle->GetGlobalScopeObject(frame.get(), debug_info);
} }
...@@ -781,14 +781,14 @@ Handle<JSObject> WasmDebugInfo::GetGlobalScopeObject( ...@@ -781,14 +781,14 @@ Handle<JSObject> WasmDebugInfo::GetGlobalScopeObject(
// static // static
Handle<JSObject> WasmDebugInfo::GetLocalScopeObject( Handle<JSObject> WasmDebugInfo::GetLocalScopeObject(
Handle<WasmDebugInfo> debug_info, Address frame_pointer, int frame_index) { Handle<WasmDebugInfo> debug_info, Address frame_pointer, int frame_index) {
InterpreterHandle* interp_handle = GetInterpreterHandle(*debug_info); auto* interp_handle = GetInterpreterHandle(*debug_info);
auto frame = interp_handle->GetInterpretedFrame(frame_pointer, frame_index); auto frame = interp_handle->GetInterpretedFrame(frame_pointer, frame_index);
return interp_handle->GetLocalScopeObject(frame.get(), debug_info); return interp_handle->GetLocalScopeObject(frame.get(), debug_info);
} }
// static // static
Handle<JSFunction> WasmDebugInfo::GetCWasmEntry( Handle<JSFunction> WasmDebugInfo::GetCWasmEntry(
Handle<WasmDebugInfo> debug_info, FunctionSig* sig) { Handle<WasmDebugInfo> debug_info, wasm::FunctionSig* sig) {
Isolate* isolate = debug_info->GetIsolate(); Isolate* isolate = debug_info->GetIsolate();
DCHECK_EQ(debug_info->has_c_wasm_entries(), DCHECK_EQ(debug_info->has_c_wasm_entries(),
debug_info->has_c_wasm_entry_map()); debug_info->has_c_wasm_entry_map());
...@@ -826,3 +826,6 @@ Handle<JSFunction> WasmDebugInfo::GetCWasmEntry( ...@@ -826,3 +826,6 @@ Handle<JSFunction> WasmDebugInfo::GetCWasmEntry(
} }
return handle(JSFunction::cast(entries->get(index))); return handle(JSFunction::cast(entries->get(index)));
} }
} // namespace internal
} // namespace v8
This diff is collapsed.
...@@ -14,20 +14,9 @@ ...@@ -14,20 +14,9 @@
#include "src/wasm/wasm-opcodes.h" #include "src/wasm/wasm-opcodes.h"
#include "src/zone/zone.h" #include "src/zone/zone.h"
#if __clang__ namespace v8 {
// TODO(mostynb@opera.com): remove the using statements and these pragmas. namespace internal {
#pragma clang diagnostic push namespace wasm {
#pragma clang diagnostic ignored "-Wheader-hygiene"
#endif
using namespace v8;
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
namespace { namespace {
bool IsValidFunctionName(const Vector<const char> &name) { bool IsValidFunctionName(const Vector<const char> &name) {
...@@ -43,10 +32,9 @@ bool IsValidFunctionName(const Vector<const char> &name) { ...@@ -43,10 +32,9 @@ bool IsValidFunctionName(const Vector<const char> &name) {
} // namespace } // namespace
void wasm::PrintWasmText(const WasmModule *module, void PrintWasmText(const WasmModule* module, const ModuleWireBytes& wire_bytes,
const ModuleWireBytes &wire_bytes, uint32_t func_index, uint32_t func_index, std::ostream& os,
std::ostream &os, debug::WasmDisassembly::OffsetTable* offset_table) {
debug::WasmDisassembly::OffsetTable *offset_table) {
DCHECK_NOT_NULL(module); DCHECK_NOT_NULL(module);
DCHECK_GT(module->functions.size(), func_index); DCHECK_GT(module->functions.size(), func_index);
const WasmFunction *fun = &module->functions[func_index]; const WasmFunction *fun = &module->functions[func_index];
...@@ -225,3 +213,7 @@ void wasm::PrintWasmText(const WasmModule *module, ...@@ -225,3 +213,7 @@ void wasm::PrintWasmText(const WasmModule *module,
DCHECK_EQ(0, control_depth); DCHECK_EQ(0, control_depth);
DCHECK(i.ok()); DCHECK(i.ok());
} }
} // namespace wasm
} // namespace internal
} // namespace v8
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment