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