From 6d71da11fdfae385f670bcfa0827b865789e9d90 Mon Sep 17 00:00:00 2001 From: "mikhail.naganov@gmail.com" Date: Mon, 25 May 2009 08:39:22 +0000 Subject: [PATCH] Merge in changes from readability review. All changes from http://codereview.chromium.org/115024, except splitting namespace declarations in two lines (will be done separately for all source files). Review URL: http://codereview.chromium.org/113763 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2037 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/codegen.cc | 2 +- src/compiler.cc | 4 +- src/func-name-inferrer.h | 32 ++++--- src/log.cc | 142 +++++++++++++++++--------------- src/log.h | 4 +- test/cctest/test-func-name-inference.cc | 17 ++-- 6 files changed, 112 insertions(+), 89 deletions(-) diff --git a/src/codegen.cc b/src/codegen.cc index 5405bf4..cb23645 100644 --- a/src/codegen.cc +++ b/src/codegen.cc @@ -211,7 +211,7 @@ Handle CodeGenerator::MakeCode(FunctionLiteral* flit, bool CodeGenerator::ShouldGenerateLog(Expression* type) { ASSERT(type != NULL); - if (!Logger::is_enabled()) return false; + if (!Logger::IsEnabled()) return false; Handle name = Handle::cast(type->AsLiteral()->handle()); if (FLAG_log_regexp) { static Vector kRegexp = CStrVector("regexp"); diff --git a/src/compiler.cc b/src/compiler.cc index 0a8e5cc..e9ce5ba 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -159,7 +159,7 @@ static Handle MakeFunction(bool is_global, #if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT // Log the code generation for the script. Check explicit whether logging is // to avoid allocating when not required. - if (Logger::is_enabled() || OProfileAgent::is_enabled()) { + if (Logger::IsEnabled() || OProfileAgent::is_enabled()) { if (script->name()->IsString()) { SmartPointer data = String::cast(script->name())->ToCString(DISALLOW_NULLS); @@ -356,7 +356,7 @@ bool Compiler::CompileLazy(Handle shared, // Log the code generation. If source information is available include script // name and line number. Check explicit whether logging is enabled as finding // the line number is not for free. - if (Logger::is_enabled() || OProfileAgent::is_enabled()) { + if (Logger::IsEnabled() || OProfileAgent::is_enabled()) { Handle func_name(name->length() > 0 ? *name : shared->inferred_name()); if (script->name()->IsString()) { diff --git a/src/func-name-inferrer.h b/src/func-name-inferrer.h index c5c81eb..a2738cb 100644 --- a/src/func-name-inferrer.h +++ b/src/func-name-inferrer.h @@ -34,41 +34,46 @@ namespace v8 { namespace internal { // inference for anonymous functions during static analysis of source code. // Inference is performed in cases when an anonymous function is assigned // to a variable or a property (see test-func-name-inference.cc for examples.) - +// // The basic idea is that during AST traversal LHSs of expressions are // always visited before RHSs. Thus, during visiting the LHS, a name can be // collected, and during visiting the RHS, a function literal can be collected. // Inference is performed while leaving the assignment node. - class FuncNameInferrer BASE_EMBEDDED { public: - FuncNameInferrer() : - entries_stack_(10), - names_stack_(5), - funcs_to_infer_(4), - dot_(Factory::NewStringFromAscii(CStrVector("."))) { + FuncNameInferrer() + : entries_stack_(10), + names_stack_(5), + funcs_to_infer_(4), + dot_(Factory::NewStringFromAscii(CStrVector("."))) { } + // Returns whether we have entered name collection state. bool IsOpen() const { return !entries_stack_.is_empty(); } + // Pushes an enclosing the name of enclosing function onto names stack. void PushEnclosingName(Handle name); + // Enters name collection state. void Enter() { entries_stack_.Add(names_stack_.length()); } + // Pushes an encountered name onto names stack when in collection state. void PushName(Handle name) { if (IsOpen()) { names_stack_.Add(name); } } + // Adds a function to infer name for. void AddFunction(FunctionLiteral* func_to_infer) { if (IsOpen()) { funcs_to_infer_.Add(func_to_infer); } } + // Infers a function name and leaves names collection state. void InferAndLeave() { ASSERT(IsOpen()); if (!funcs_to_infer_.is_empty()) { @@ -78,8 +83,13 @@ class FuncNameInferrer BASE_EMBEDDED { } private: + // Constructs a full name in dotted notation from gathered names. Handle MakeNameFromStack(); + + // A helper function for MakeNameFromStack. Handle MakeNameFromStackHelper(int pos, Handle prev); + + // Performs name inferring for added functions. void InferFunctionsNames(); ZoneList entries_stack_; @@ -95,15 +105,17 @@ class FuncNameInferrer BASE_EMBEDDED { // leaving scope. class ScopedFuncNameInferrer BASE_EMBEDDED { public: - explicit ScopedFuncNameInferrer(FuncNameInferrer* inferrer) : - inferrer_(inferrer), - is_entered_(false) {} + explicit ScopedFuncNameInferrer(FuncNameInferrer* inferrer) + : inferrer_(inferrer), + is_entered_(false) {} + ~ScopedFuncNameInferrer() { if (is_entered_) { inferrer_->InferAndLeave(); } } + // Triggers the wrapped inferrer into name collection state. void Enter() { inferrer_->Enter(); is_entered_ = true; diff --git a/src/log.cc b/src/log.cc index d5701f5..8701f9b 100644 --- a/src/log.cc +++ b/src/log.cc @@ -303,30 +303,37 @@ class Log : public AllStatic { // Frees all resources acquired in Open... functions. static void Close(); - // See description in v8.h. + // See description in include/v8.h. static int GetLogLines(int from_pos, char* dest_buf, int max_size); - static bool is_enabled() { return output_.handle != NULL; } + // Returns whether logging is enabled. + static bool IsEnabled() { + return output_handle_ != NULL || output_buffer_ != NULL; + } - typedef int (*WritePtr)(const char* msg, int length); private: + typedef int (*WritePtr)(const char* msg, int length); + + // Initialization function called from Open... functions. static void Init(); // Write functions assume that mutex_ is acquired by the caller. static WritePtr Write; + // Implementation of writing to a log file. static int WriteToFile(const char* msg, int length) { - ASSERT(output_.handle != NULL); - int rv = fwrite(msg, 1, length, output_.handle); + ASSERT(output_handle_ != NULL); + int rv = fwrite(msg, 1, length, output_handle_); ASSERT(length == rv); return rv; } + // Implementation of writing to a memory buffer. static int WriteToMemory(const char* msg, int length) { - ASSERT(output_.buffer != NULL); - ASSERT(output_buffer_write_pos_ >= output_.buffer); + ASSERT(output_buffer_ != NULL); + ASSERT(output_buffer_write_pos_ >= output_buffer_); if (output_buffer_write_pos_ + length - <= output_.buffer + kOutputBufferSize) { + <= output_buffer_ + kOutputBufferSize) { memcpy(output_buffer_write_pos_, msg, length); output_buffer_write_pos_ += length; return length; @@ -336,14 +343,14 @@ class Log : public AllStatic { } } - // When logging is active, output_ refers the file or memory buffer - // events are written to. - // mutex_ should be acquired before using output_. - union Output { - FILE* handle; - char* buffer; - }; - static Output output_; + // When logging is active, either output_handle_ or output_buffer_ is used + // to store a pointer to log destination. If logging was opened via OpenStdout + // or OpenFile, then output_handle_ is used. If logging was opened + // via OpenMemoryBuffer, then output_buffer_ is used. + // mutex_ should be acquired before using output_handle_ or output_buffer_. + static FILE* output_handle_; + + static char* output_buffer_; // mutex_ is a Mutex used for enforcing exclusive // access to the formatting buffer and the log file or log memory buffer. @@ -367,7 +374,8 @@ class Log : public AllStatic { Log::WritePtr Log::Write = NULL; -Log::Output Log::output_ = {NULL}; +FILE* Log::output_handle_ = NULL; +char* Log::output_buffer_ = NULL; Mutex* Log::mutex_ = NULL; char* Log::output_buffer_write_pos_ = NULL; char* Log::message_buffer_ = NULL; @@ -380,25 +388,25 @@ void Log::Init() { void Log::OpenStdout() { - ASSERT(output_.handle == NULL); - output_.handle = stdout; + ASSERT(!IsEnabled()); + output_handle_ = stdout; Write = WriteToFile; Init(); } void Log::OpenFile(const char* name) { - ASSERT(output_.handle == NULL); - output_.handle = OS::FOpen(name, OS::LogFileOpenMode); + ASSERT(!IsEnabled()); + output_handle_ = OS::FOpen(name, OS::LogFileOpenMode); Write = WriteToFile; Init(); } void Log::OpenMemoryBuffer() { - ASSERT(output_.buffer == NULL); - output_.buffer = NewArray(kOutputBufferSize); - output_buffer_write_pos_ = output_.buffer; + ASSERT(!IsEnabled()); + output_buffer_ = NewArray(kOutputBufferSize); + output_buffer_write_pos_ = output_buffer_; Write = WriteToMemory; Init(); } @@ -406,11 +414,11 @@ void Log::OpenMemoryBuffer() { void Log::Close() { if (Write == WriteToFile) { - fclose(output_.handle); - output_.handle = NULL; + fclose(output_handle_); + output_handle_ = NULL; } else if (Write == WriteToMemory) { - DeleteArray(output_.buffer); - output_.buffer = NULL; + DeleteArray(output_buffer_); + output_buffer_ = NULL; } else { ASSERT(Write == NULL); } @@ -426,15 +434,15 @@ void Log::Close() { int Log::GetLogLines(int from_pos, char* dest_buf, int max_size) { if (Write != WriteToMemory) return 0; - ASSERT(output_.buffer != NULL); - ASSERT(output_buffer_write_pos_ >= output_.buffer); + ASSERT(output_buffer_ != NULL); + ASSERT(output_buffer_write_pos_ >= output_buffer_); ASSERT(from_pos >= 0); ASSERT(max_size >= 0); int actual_size = max_size; - char* buffer_read_pos = output_.buffer + from_pos; + char* buffer_read_pos = output_buffer_ + from_pos; ScopedLock sl(mutex_); if (actual_size == 0 - || output_buffer_write_pos_ == output_.buffer + || output_buffer_write_pos_ == output_buffer_ || buffer_read_pos >= output_buffer_write_pos_) { // No data requested or can be returned. return 0; @@ -586,8 +594,8 @@ VMState Logger::bottom_state_(EXTERNAL); SlidingStateWindow* Logger::sliding_state_window_ = NULL; -bool Logger::is_enabled() { - return Log::is_enabled(); +bool Logger::IsEnabled() { + return Log::IsEnabled(); } #endif // ENABLE_LOGGING_AND_PROFILING @@ -595,7 +603,7 @@ bool Logger::is_enabled() { void Logger::Preamble(const char* content) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_code) return; + if (!Log::IsEnabled() || !FLAG_log_code) return; LogMessageBuilder msg; msg.WriteCStringToLogFile(content); #endif @@ -611,7 +619,7 @@ void Logger::StringEvent(const char* name, const char* value) { #ifdef ENABLE_LOGGING_AND_PROFILING void Logger::UncheckedStringEvent(const char* name, const char* value) { - if (!Log::is_enabled()) return; + if (!Log::IsEnabled()) return; LogMessageBuilder msg; msg.Append("%s,\"%s\"\n", name, value); msg.WriteToLogFile(); @@ -621,7 +629,7 @@ void Logger::UncheckedStringEvent(const char* name, const char* value) { void Logger::IntEvent(const char* name, int value) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log) return; + if (!Log::IsEnabled() || !FLAG_log) return; LogMessageBuilder msg; msg.Append("%s,%d\n", name, value); msg.WriteToLogFile(); @@ -631,7 +639,7 @@ void Logger::IntEvent(const char* name, int value) { void Logger::HandleEvent(const char* name, Object** location) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_handles) return; + if (!Log::IsEnabled() || !FLAG_log_handles) return; LogMessageBuilder msg; msg.Append("%s,0x%" V8PRIxPTR "\n", name, location); msg.WriteToLogFile(); @@ -644,7 +652,7 @@ void Logger::HandleEvent(const char* name, Object** location) { // caller's responsibility to ensure that log is enabled and that // FLAG_log_api is true. void Logger::ApiEvent(const char* format, ...) { - ASSERT(Log::is_enabled() && FLAG_log_api); + ASSERT(Log::IsEnabled() && FLAG_log_api); LogMessageBuilder msg; va_list ap; va_start(ap, format); @@ -657,7 +665,7 @@ void Logger::ApiEvent(const char* format, ...) { void Logger::ApiNamedSecurityCheck(Object* key) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_api) return; + if (!Log::IsEnabled() || !FLAG_log_api) return; if (key->IsString()) { SmartPointer str = String::cast(key)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); @@ -675,7 +683,7 @@ void Logger::SharedLibraryEvent(const char* library_path, unsigned start, unsigned end) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_prof) return; + if (!Log::IsEnabled() || !FLAG_prof) return; LogMessageBuilder msg; msg.Append("shared-library,\"%s\",0x%08x,0x%08x\n", library_path, start, end); @@ -688,7 +696,7 @@ void Logger::SharedLibraryEvent(const wchar_t* library_path, unsigned start, unsigned end) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_prof) return; + if (!Log::IsEnabled() || !FLAG_prof) return; LogMessageBuilder msg; msg.Append("shared-library,\"%ls\",0x%08x,0x%08x\n", library_path, start, end); @@ -743,7 +751,7 @@ void Logger::LogRegExpSource(Handle regexp) { void Logger::RegExpCompileEvent(Handle regexp, bool in_cache) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_regexp) return; + if (!Log::IsEnabled() || !FLAG_log_regexp) return; LogMessageBuilder msg; msg.Append("regexp-compile,"); LogRegExpSource(regexp); @@ -755,7 +763,7 @@ void Logger::RegExpCompileEvent(Handle regexp, bool in_cache) { void Logger::LogRuntime(Vector format, JSArray* args) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_runtime) return; + if (!Log::IsEnabled() || !FLAG_log_runtime) return; HandleScope scope; LogMessageBuilder msg; for (int i = 0; i < format.length(); i++) { @@ -796,7 +804,7 @@ void Logger::LogRuntime(Vector format, JSArray* args) { void Logger::ApiIndexedSecurityCheck(uint32_t index) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_api) return; + if (!Log::IsEnabled() || !FLAG_log_api) return; ApiEvent("api,check-security,%u\n", index); #endif } @@ -807,7 +815,7 @@ void Logger::ApiNamedPropertyAccess(const char* tag, Object* name) { #ifdef ENABLE_LOGGING_AND_PROFILING ASSERT(name->IsString()); - if (!Log::is_enabled() || !FLAG_log_api) return; + if (!Log::IsEnabled() || !FLAG_log_api) return; String* class_name_obj = holder->class_name(); SmartPointer class_name = class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); @@ -821,7 +829,7 @@ void Logger::ApiIndexedPropertyAccess(const char* tag, JSObject* holder, uint32_t index) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_api) return; + if (!Log::IsEnabled() || !FLAG_log_api) return; String* class_name_obj = holder->class_name(); SmartPointer class_name = class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); @@ -831,7 +839,7 @@ void Logger::ApiIndexedPropertyAccess(const char* tag, void Logger::ApiObjectAccess(const char* tag, JSObject* object) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_api) return; + if (!Log::IsEnabled() || !FLAG_log_api) return; String* class_name_obj = object->class_name(); SmartPointer class_name = class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); @@ -842,7 +850,7 @@ void Logger::ApiObjectAccess(const char* tag, JSObject* object) { void Logger::ApiEntryCall(const char* name) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_api) return; + if (!Log::IsEnabled() || !FLAG_log_api) return; Logger::ApiEvent("api,%s\n", name); #endif } @@ -850,7 +858,7 @@ void Logger::ApiEntryCall(const char* name) { void Logger::NewEvent(const char* name, void* object, size_t size) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log) return; + if (!Log::IsEnabled() || !FLAG_log) return; LogMessageBuilder msg; msg.Append("new,%s,0x%" V8PRIxPTR ",%u\n", name, object, static_cast(size)); @@ -861,7 +869,7 @@ void Logger::NewEvent(const char* name, void* object, size_t size) { void Logger::DeleteEvent(const char* name, void* object) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log) return; + if (!Log::IsEnabled() || !FLAG_log) return; LogMessageBuilder msg; msg.Append("delete,%s,0x%" V8PRIxPTR "\n", name, object); msg.WriteToLogFile(); @@ -871,7 +879,7 @@ void Logger::DeleteEvent(const char* name, void* object) { void Logger::CodeCreateEvent(const char* tag, Code* code, const char* comment) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_code) return; + if (!Log::IsEnabled() || !FLAG_log_code) return; LogMessageBuilder msg; msg.Append("code-creation,%s,0x%" V8PRIxPTR ",%d,\"", tag, code->address(), code->ExecutableSize()); @@ -890,7 +898,7 @@ void Logger::CodeCreateEvent(const char* tag, Code* code, const char* comment) { void Logger::CodeCreateEvent(const char* tag, Code* code, String* name) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_code) return; + if (!Log::IsEnabled() || !FLAG_log_code) return; LogMessageBuilder msg; SmartPointer str = name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); @@ -904,7 +912,7 @@ void Logger::CodeCreateEvent(const char* tag, Code* code, String* name) { void Logger::CodeCreateEvent(const char* tag, Code* code, String* name, String* source, int line) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_code) return; + if (!Log::IsEnabled() || !FLAG_log_code) return; LogMessageBuilder msg; SmartPointer str = name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); @@ -921,7 +929,7 @@ void Logger::CodeCreateEvent(const char* tag, Code* code, String* name, void Logger::CodeCreateEvent(const char* tag, Code* code, int args_count) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_code) return; + if (!Log::IsEnabled() || !FLAG_log_code) return; LogMessageBuilder msg; msg.Append("code-creation,%s,0x%" V8PRIxPTR ",%d,\"args_count: %d\"\n", tag, code->address(), @@ -934,7 +942,7 @@ void Logger::CodeCreateEvent(const char* tag, Code* code, int args_count) { void Logger::RegExpCodeCreateEvent(Code* code, String* source) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_code) return; + if (!Log::IsEnabled() || !FLAG_log_code) return; LogMessageBuilder msg; msg.Append("code-creation,%s,0x%" V8PRIxPTR ",%d,\"", "RegExp", code->address(), @@ -948,7 +956,7 @@ void Logger::RegExpCodeCreateEvent(Code* code, String* source) { void Logger::CodeAllocateEvent(Code* code, Assembler* assem) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_code) return; + if (!Log::IsEnabled() || !FLAG_log_code) return; LogMessageBuilder msg; msg.Append("code-allocate,0x%" V8PRIxPTR ",0x%" V8PRIxPTR "\n", code->address(), @@ -960,7 +968,7 @@ void Logger::CodeAllocateEvent(Code* code, Assembler* assem) { void Logger::CodeMoveEvent(Address from, Address to) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_code) return; + if (!Log::IsEnabled() || !FLAG_log_code) return; LogMessageBuilder msg; msg.Append("code-move,0x%" V8PRIxPTR ",0x%" V8PRIxPTR "\n", from, to); msg.WriteToLogFile(); @@ -970,7 +978,7 @@ void Logger::CodeMoveEvent(Address from, Address to) { void Logger::CodeDeleteEvent(Address from) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_code) return; + if (!Log::IsEnabled() || !FLAG_log_code) return; LogMessageBuilder msg; msg.Append("code-delete,0x%" V8PRIxPTR "\n", from); msg.WriteToLogFile(); @@ -980,7 +988,7 @@ void Logger::CodeDeleteEvent(Address from) { void Logger::ResourceEvent(const char* name, const char* tag) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log) return; + if (!Log::IsEnabled() || !FLAG_log) return; LogMessageBuilder msg; msg.Append("%s,%s,", name, tag); @@ -998,7 +1006,7 @@ void Logger::ResourceEvent(const char* name, const char* tag) { void Logger::SuspectReadEvent(String* name, Object* obj) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_suspect) return; + if (!Log::IsEnabled() || !FLAG_log_suspect) return; LogMessageBuilder msg; String* class_name = obj->IsJSObject() ? JSObject::cast(obj)->class_name() @@ -1017,7 +1025,7 @@ void Logger::SuspectReadEvent(String* name, Object* obj) { void Logger::HeapSampleBeginEvent(const char* space, const char* kind) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_gc) return; + if (!Log::IsEnabled() || !FLAG_log_gc) return; LogMessageBuilder msg; msg.Append("heap-sample-begin,\"%s\",\"%s\"\n", space, kind); msg.WriteToLogFile(); @@ -1027,7 +1035,7 @@ void Logger::HeapSampleBeginEvent(const char* space, const char* kind) { void Logger::HeapSampleEndEvent(const char* space, const char* kind) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_gc) return; + if (!Log::IsEnabled() || !FLAG_log_gc) return; LogMessageBuilder msg; msg.Append("heap-sample-end,\"%s\",\"%s\"\n", space, kind); msg.WriteToLogFile(); @@ -1037,7 +1045,7 @@ void Logger::HeapSampleEndEvent(const char* space, const char* kind) { void Logger::HeapSampleItemEvent(const char* type, int number, int bytes) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log_gc) return; + if (!Log::IsEnabled() || !FLAG_log_gc) return; LogMessageBuilder msg; msg.Append("heap-sample-item,%s,%d,%d\n", type, number, bytes); msg.WriteToLogFile(); @@ -1047,7 +1055,7 @@ void Logger::HeapSampleItemEvent(const char* type, int number, int bytes) { void Logger::DebugTag(const char* call_site_tag) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log) return; + if (!Log::IsEnabled() || !FLAG_log) return; LogMessageBuilder msg; msg.Append("debug-tag,%s\n", call_site_tag); msg.WriteToLogFile(); @@ -1057,7 +1065,7 @@ void Logger::DebugTag(const char* call_site_tag) { void Logger::DebugEvent(const char* event_type, Vector parameter) { #ifdef ENABLE_LOGGING_AND_PROFILING - if (!Log::is_enabled() || !FLAG_log) return; + if (!Log::IsEnabled() || !FLAG_log) return; StringBuilder s(parameter.length() + 1); for (int i = 0; i < parameter.length(); ++i) { s.AddCharacter(static_cast(parameter[i])); @@ -1076,7 +1084,7 @@ void Logger::DebugEvent(const char* event_type, Vector parameter) { #ifdef ENABLE_LOGGING_AND_PROFILING void Logger::TickEvent(TickSample* sample, bool overflow) { - if (!Log::is_enabled() || !FLAG_prof) return; + if (!Log::IsEnabled() || !FLAG_prof) return; LogMessageBuilder msg; msg.Append("tick,0x%" V8PRIxPTR ",0x%" V8PRIxPTR ",%d", sample->pc, sample->sp, static_cast(sample->state)); diff --git a/src/log.h b/src/log.h index fc0b9f9..4630943 100644 --- a/src/log.h +++ b/src/log.h @@ -75,7 +75,7 @@ class LogMessageBuilder; #ifdef ENABLE_LOGGING_AND_PROFILING #define LOG(Call) \ do { \ - if (v8::internal::Logger::is_enabled()) \ + if (v8::internal::Logger::IsEnabled()) \ v8::internal::Logger::Call; \ } while (false) #else @@ -201,7 +201,7 @@ class Logger { return current_state_ ? current_state_->state() : OTHER; } - static bool is_enabled(); + static bool IsEnabled(); // Pause/Resume collection of profiling data. // When data collection is paused, Tick events are discarded until diff --git a/test/cctest/test-func-name-inference.cc b/test/cctest/test-func-name-inference.cc index d91f75f..1bfc883 100644 --- a/test/cctest/test-func-name-inference.cc +++ b/test/cctest/test-func-name-inference.cc @@ -32,15 +32,18 @@ #include "cctest.h" +using ::v8::internal::CStrVector; +using ::v8::internal::Factory; using ::v8::internal::Handle; +using ::v8::internal::Heap; using ::v8::internal::JSFunction; using ::v8::internal::Object; +using ::v8::internal::Runtime; using ::v8::internal::Script; +using ::v8::internal::SmartPointer; using ::v8::internal::SharedFunctionInfo; using ::v8::internal::String; -namespace i = ::v8::internal; - static v8::Persistent env; @@ -66,19 +69,19 @@ static void CheckFunctionName(v8::Handle script, // Find the position of a given func source substring in the source. Handle func_pos_str = - i::Factory::NewStringFromAscii(i::CStrVector(func_pos_src)); - int func_pos = i::Runtime::StringMatch(script_src, func_pos_str, 0); + Factory::NewStringFromAscii(CStrVector(func_pos_src)); + int func_pos = Runtime::StringMatch(script_src, func_pos_str, 0); CHECK_NE(0, func_pos); // Obtain SharedFunctionInfo for the function. Object* shared_func_info_ptr = - i::Runtime::FindSharedFunctionInfoInScript(i_script, func_pos); - CHECK(shared_func_info_ptr != i::Heap::undefined_value()); + Runtime::FindSharedFunctionInfoInScript(i_script, func_pos); + CHECK(shared_func_info_ptr != Heap::undefined_value()); Handle shared_func_info( SharedFunctionInfo::cast(shared_func_info_ptr)); // Verify inferred function name. - i::SmartPointer inferred_name = + SmartPointer inferred_name = shared_func_info->inferred_name()->ToCString(); CHECK_EQ(ref_inferred_name, *inferred_name); } -- 2.7.4