diff --git a/deps/v8/include/libplatform/v8-tracing.h b/deps/v8/include/libplatform/v8-tracing.h index e9f49414784da5..c4d8cc6b9a33da 100644 --- a/deps/v8/include/libplatform/v8-tracing.h +++ b/deps/v8/include/libplatform/v8-tracing.h @@ -36,22 +36,19 @@ class TraceObject { TraceObject() {} ~TraceObject(); - void Initialize( - char phase, const uint8_t* category_enabled_flag, const char* name, - const char* scope, uint64_t id, uint64_t bind_id, int num_args, - const char** arg_names, const uint8_t* arg_types, - const uint64_t* arg_values, - std::unique_ptr* arg_convertables, - unsigned int flags); + void Initialize(char phase, const uint8_t* category_enabled_flag, + const char* name, const char* scope, uint64_t id, + uint64_t bind_id, int num_args, const char** arg_names, + const uint8_t* arg_types, const uint64_t* arg_values, + unsigned int flags); void UpdateDuration(); - void InitializeForTesting( - char phase, const uint8_t* category_enabled_flag, const char* name, - const char* scope, uint64_t id, uint64_t bind_id, int num_args, - const char** arg_names, const uint8_t* arg_types, - const uint64_t* arg_values, - std::unique_ptr* arg_convertables, - unsigned int flags, int pid, int tid, int64_t ts, int64_t tts, - uint64_t duration, uint64_t cpu_duration); + void InitializeForTesting(char phase, const uint8_t* category_enabled_flag, + const char* name, const char* scope, uint64_t id, + uint64_t bind_id, int num_args, + const char** arg_names, const uint8_t* arg_types, + const uint64_t* arg_values, unsigned int flags, + int pid, int tid, int64_t ts, int64_t tts, + uint64_t duration, uint64_t cpu_duration); int pid() const { return pid_; } int tid() const { return tid_; } @@ -67,9 +64,6 @@ class TraceObject { const char** arg_names() { return arg_names_; } uint8_t* arg_types() { return arg_types_; } ArgValue* arg_values() { return arg_values_; } - std::unique_ptr* arg_convertables() { - return arg_convertables_; - } unsigned int flags() const { return flags_; } int64_t ts() { return ts_; } int64_t tts() { return tts_; } @@ -85,12 +79,10 @@ class TraceObject { const uint8_t* category_enabled_flag_; uint64_t id_; uint64_t bind_id_; - int num_args_ = 0; + int num_args_; const char* arg_names_[kTraceMaxNumArgs]; uint8_t arg_types_[kTraceMaxNumArgs]; ArgValue arg_values_[kTraceMaxNumArgs]; - std::unique_ptr - arg_convertables_[kTraceMaxNumArgs]; char* parameter_copy_storage_ = nullptr; unsigned int flags_; int64_t ts_; @@ -238,13 +230,11 @@ class TracingController { void Initialize(TraceBuffer* trace_buffer); const uint8_t* GetCategoryGroupEnabled(const char* category_group); static const char* GetCategoryGroupName(const uint8_t* category_enabled_flag); - uint64_t AddTraceEvent( - char phase, const uint8_t* category_enabled_flag, const char* name, - const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args, - const char** arg_names, const uint8_t* arg_types, - const uint64_t* arg_values, - std::unique_ptr* arg_convertables, - unsigned int flags); + uint64_t AddTraceEvent(char phase, const uint8_t* category_enabled_flag, + const char* name, const char* scope, uint64_t id, + uint64_t bind_id, int32_t num_args, + const char** arg_names, const uint8_t* arg_types, + const uint64_t* arg_values, unsigned int flags); void UpdateTraceEventDuration(const uint8_t* category_enabled_flag, const char* name, uint64_t handle); diff --git a/deps/v8/include/v8-platform.h b/deps/v8/include/v8-platform.h index e11567488b6a3c..d0b7aed8fc5a33 100644 --- a/deps/v8/include/v8-platform.h +++ b/deps/v8/include/v8-platform.h @@ -7,8 +7,6 @@ #include #include -#include -#include namespace v8 { @@ -19,38 +17,24 @@ class Isolate; */ class Task { public: - virtual ~Task() = default; + virtual ~Task() {} virtual void Run() = 0; }; + /** - * An IdleTask represents a unit of work to be performed in idle time. - * The Run method is invoked with an argument that specifies the deadline in - * seconds returned by MonotonicallyIncreasingTime(). - * The idle task is expected to complete by this deadline. - */ +* An IdleTask represents a unit of work to be performed in idle time. +* The Run method is invoked with an argument that specifies the deadline in +* seconds returned by MonotonicallyIncreasingTime(). +* The idle task is expected to complete by this deadline. +*/ class IdleTask { public: - virtual ~IdleTask() = default; + virtual ~IdleTask() {} virtual void Run(double deadline_in_seconds) = 0; }; -/** - * The interface represents complex arguments to trace events. - */ -class ConvertableToTraceFormat { - public: - virtual ~ConvertableToTraceFormat() = default; - - /** - * Append the class info to the provided |out| string. The appended - * data must be a valid JSON object. Strings must be properly quoted, and - * escaped. There is no processing applied to the content after it is - * appended. - */ - virtual void AppendAsTraceFormat(std::string* out) const = 0; -}; /** * V8 Platform abstraction layer. @@ -70,7 +54,7 @@ class Platform { kLongRunningTask }; - virtual ~Platform() = default; + virtual ~Platform() {} /** * Gets the number of threads that are used to execute background tasks. Is @@ -174,25 +158,6 @@ class Platform { return 0; } - /** - * Adds a trace event to the platform tracing system. This function call is - * usually the result of a TRACE_* macro from trace_event_common.h when - * tracing and the category of the particular trace are enabled. It is not - * advisable to call this function on its own; it is really only meant to be - * used by the trace macros. The returned handle can be used by - * UpdateTraceEventDuration to update the duration of COMPLETE events. - */ - virtual uint64_t AddTraceEvent( - char phase, const uint8_t* category_enabled_flag, const char* name, - const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args, - const char** arg_names, const uint8_t* arg_types, - const uint64_t* arg_values, - std::unique_ptr* arg_convertables, - unsigned int flags) { - return AddTraceEvent(phase, category_enabled_flag, name, scope, id, bind_id, - num_args, arg_names, arg_types, arg_values, flags); - } - /** * Sets the duration field of a COMPLETE trace event. It must be called with * the handle returned from AddTraceEvent(). diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index 36edf5334a9d27..8189c7cf3bf345 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -5228,27 +5228,6 @@ struct NamedPropertyHandlerConfiguration { query(query), deleter(deleter), enumerator(enumerator), - definer(0), - descriptor(0), - data(data), - flags(flags) {} - - NamedPropertyHandlerConfiguration( - GenericNamedPropertyGetterCallback getter, - GenericNamedPropertySetterCallback setter, - GenericNamedPropertyDescriptorCallback descriptor, - GenericNamedPropertyDeleterCallback deleter, - GenericNamedPropertyEnumeratorCallback enumerator, - GenericNamedPropertyDefinerCallback definer, - Local data = Local(), - PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) - : getter(getter), - setter(setter), - query(0), - deleter(deleter), - enumerator(enumerator), - definer(definer), - descriptor(descriptor), data(data), flags(flags) {} @@ -5257,8 +5236,6 @@ struct NamedPropertyHandlerConfiguration { GenericNamedPropertyQueryCallback query; GenericNamedPropertyDeleterCallback deleter; GenericNamedPropertyEnumeratorCallback enumerator; - GenericNamedPropertyDefinerCallback definer; - GenericNamedPropertyDescriptorCallback descriptor; Local data; PropertyHandlerFlags flags; }; @@ -5279,27 +5256,6 @@ struct IndexedPropertyHandlerConfiguration { query(query), deleter(deleter), enumerator(enumerator), - definer(0), - descriptor(0), - data(data), - flags(flags) {} - - IndexedPropertyHandlerConfiguration( - IndexedPropertyGetterCallback getter, - IndexedPropertySetterCallback setter, - IndexedPropertyDescriptorCallback descriptor, - IndexedPropertyDeleterCallback deleter, - IndexedPropertyEnumeratorCallback enumerator, - IndexedPropertyDefinerCallback definer, - Local data = Local(), - PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) - : getter(getter), - setter(setter), - query(0), - deleter(deleter), - enumerator(enumerator), - definer(definer), - descriptor(descriptor), data(data), flags(flags) {} @@ -5308,8 +5264,6 @@ struct IndexedPropertyHandlerConfiguration { IndexedPropertyQueryCallback query; IndexedPropertyDeleterCallback deleter; IndexedPropertyEnumeratorCallback enumerator; - IndexedPropertyDefinerCallback definer; - IndexedPropertyDescriptorCallback descriptor; Local data; PropertyHandlerFlags flags; }; @@ -8289,8 +8243,8 @@ class Internals { static const int kNodeIsPartiallyDependentShift = 4; static const int kNodeIsActiveShift = 4; - static const int kJSObjectType = 0xb9; - static const int kJSApiObjectType = 0xb8; + static const int kJSObjectType = 0xb7; + static const int kJSApiObjectType = 0xb6; static const int kFirstNonstringType = 0x80; static const int kOddballType = 0x83; static const int kForeignType = 0x87; diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index 44933b965becb8..c2c57b4e587fc5 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -1579,8 +1579,8 @@ void ObjectTemplate::SetNamedPropertyHandler( void ObjectTemplate::SetHandler( const NamedPropertyHandlerConfiguration& config) { ObjectTemplateSetNamedPropertyHandler( - this, config.getter, config.setter, config.query, config.descriptor, - config.deleter, config.enumerator, config.definer, config.data, + this, config.getter, config.setter, config.query, nullptr, + config.deleter, config.enumerator, nullptr, config.data, config.flags); } @@ -1641,14 +1641,14 @@ void ObjectTemplate::SetAccessCheckCallbackAndHandler( SET_FIELD_WRAPPED(info, set_callback, callback); auto named_interceptor = CreateInterceptorInfo( isolate, named_handler.getter, named_handler.setter, named_handler.query, - named_handler.descriptor, named_handler.deleter, named_handler.enumerator, - named_handler.definer, named_handler.data, named_handler.flags); + nullptr, named_handler.deleter, named_handler.enumerator, + nullptr, named_handler.data, named_handler.flags); info->set_named_interceptor(*named_interceptor); auto indexed_interceptor = CreateInterceptorInfo( isolate, indexed_handler.getter, indexed_handler.setter, - indexed_handler.query, indexed_handler.descriptor, + indexed_handler.query, nullptr, indexed_handler.deleter, indexed_handler.enumerator, - indexed_handler.definer, indexed_handler.data, indexed_handler.flags); + nullptr, indexed_handler.data, indexed_handler.flags); info->set_indexed_interceptor(*indexed_interceptor); if (data.IsEmpty()) { @@ -1668,9 +1668,9 @@ void ObjectTemplate::SetHandler( auto cons = EnsureConstructor(isolate, this); EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetHandler"); auto obj = CreateInterceptorInfo(isolate, config.getter, config.setter, - config.query, config.descriptor, + config.query, nullptr, config.deleter, config.enumerator, - config.definer, config.data, config.flags); + nullptr, config.data, config.flags); cons->set_indexed_property_handler(*obj); } diff --git a/deps/v8/src/libplatform/default-platform.cc b/deps/v8/src/libplatform/default-platform.cc index f64143ed248558..8686023f9dff00 100644 --- a/deps/v8/src/libplatform/default-platform.cc +++ b/deps/v8/src/libplatform/default-platform.cc @@ -178,17 +178,16 @@ double DefaultPlatform::MonotonicallyIncreasingTime() { static_cast(base::Time::kMicrosecondsPerSecond); } + uint64_t DefaultPlatform::AddTraceEvent( char phase, const uint8_t* category_enabled_flag, const char* name, const char* scope, uint64_t id, uint64_t bind_id, int num_args, const char** arg_names, const uint8_t* arg_types, - const uint64_t* arg_values, - std::unique_ptr* arg_convertables, - unsigned int flags) { + const uint64_t* arg_values, unsigned int flags) { if (tracing_controller_) { return tracing_controller_->AddTraceEvent( phase, category_enabled_flag, name, scope, id, bind_id, num_args, - arg_names, arg_types, arg_values, arg_convertables, flags); + arg_names, arg_types, arg_values, flags); } return 0; diff --git a/deps/v8/src/libplatform/default-platform.h b/deps/v8/src/libplatform/default-platform.h index e36234f528ce52..568e53fdd6f358 100644 --- a/deps/v8/src/libplatform/default-platform.h +++ b/deps/v8/src/libplatform/default-platform.h @@ -53,13 +53,12 @@ class DefaultPlatform : public Platform { const char* GetCategoryGroupName( const uint8_t* category_enabled_flag) override; using Platform::AddTraceEvent; - uint64_t AddTraceEvent( - char phase, const uint8_t* category_enabled_flag, const char* name, - const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args, - const char** arg_names, const uint8_t* arg_types, - const uint64_t* arg_values, - std::unique_ptr* arg_convertables, - unsigned int flags) override; + uint64_t AddTraceEvent(char phase, const uint8_t* category_enabled_flag, + const char* name, const char* scope, uint64_t id, + uint64_t bind_id, int32_t num_args, + const char** arg_names, const uint8_t* arg_types, + const uint64_t* arg_values, + unsigned int flags) override; void UpdateTraceEventDuration(const uint8_t* category_enabled_flag, const char* name, uint64_t handle) override; void SetTracingController(tracing::TracingController* tracing_controller); diff --git a/deps/v8/src/libplatform/tracing/trace-object.cc b/deps/v8/src/libplatform/tracing/trace-object.cc index bb4bf713907513..55be8921cb66d4 100644 --- a/deps/v8/src/libplatform/tracing/trace-object.cc +++ b/deps/v8/src/libplatform/tracing/trace-object.cc @@ -5,7 +5,6 @@ #include "include/libplatform/v8-tracing.h" #include "base/trace_event/common/trace_event_common.h" -#include "include/v8-platform.h" #include "src/base/platform/platform.h" #include "src/base/platform/time.h" @@ -31,13 +30,11 @@ V8_INLINE static void CopyTraceObjectParameter(char** buffer, } } -void TraceObject::Initialize( - char phase, const uint8_t* category_enabled_flag, const char* name, - const char* scope, uint64_t id, uint64_t bind_id, int num_args, - const char** arg_names, const uint8_t* arg_types, - const uint64_t* arg_values, - std::unique_ptr* arg_convertables, - unsigned int flags) { +void TraceObject::Initialize(char phase, const uint8_t* category_enabled_flag, + const char* name, const char* scope, uint64_t id, + uint64_t bind_id, int num_args, + const char** arg_names, const uint8_t* arg_types, + const uint64_t* arg_values, unsigned int flags) { pid_ = base::OS::GetCurrentProcessId(); tid_ = base::OS::GetCurrentThreadId(); phase_ = phase; @@ -58,8 +55,6 @@ void TraceObject::Initialize( arg_names_[i] = arg_names[i]; arg_values_[i].as_uint = arg_values[i]; arg_types_[i] = arg_types[i]; - if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE) - arg_convertables_[i] = std::move(arg_convertables[i]); } bool copy = !!(flags & TRACE_EVENT_FLAG_COPY); @@ -112,10 +107,8 @@ void TraceObject::InitializeForTesting( char phase, const uint8_t* category_enabled_flag, const char* name, const char* scope, uint64_t id, uint64_t bind_id, int num_args, const char** arg_names, const uint8_t* arg_types, - const uint64_t* arg_values, - std::unique_ptr* arg_convertables, - unsigned int flags, int pid, int tid, int64_t ts, int64_t tts, - uint64_t duration, uint64_t cpu_duration) { + const uint64_t* arg_values, unsigned int flags, int pid, int tid, + int64_t ts, int64_t tts, uint64_t duration, uint64_t cpu_duration) { pid_ = pid; tid_ = tid; phase_ = phase; diff --git a/deps/v8/src/libplatform/tracing/trace-writer.cc b/deps/v8/src/libplatform/tracing/trace-writer.cc index 7445087c565850..ec95527d5f6a89 100644 --- a/deps/v8/src/libplatform/tracing/trace-writer.cc +++ b/deps/v8/src/libplatform/tracing/trace-writer.cc @@ -7,7 +7,6 @@ #include #include "base/trace_event/common/trace_event_common.h" -#include "include/v8-platform.h" #include "src/base/platform/platform.h" namespace v8 { @@ -113,12 +112,6 @@ void JSONTraceWriter::AppendArgValue(uint8_t type, } } -void JSONTraceWriter::AppendArgValue(ConvertableToTraceFormat* value) { - std::string arg_stringified; - value->AppendAsTraceFormat(&arg_stringified); - stream_ << arg_stringified; -} - JSONTraceWriter::JSONTraceWriter(std::ostream& stream) : stream_(stream) { stream_ << "{\"traceEvents\":["; } @@ -150,16 +143,10 @@ void JSONTraceWriter::AppendTraceEvent(TraceObject* trace_event) { const char** arg_names = trace_event->arg_names(); const uint8_t* arg_types = trace_event->arg_types(); TraceObject::ArgValue* arg_values = trace_event->arg_values(); - std::unique_ptr* arg_convertables = - trace_event->arg_convertables(); for (int i = 0; i < trace_event->num_args(); ++i) { if (i > 0) stream_ << ","; stream_ << "\"" << arg_names[i] << "\":"; - if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE) { - AppendArgValue(arg_convertables[i].get()); - } else { - AppendArgValue(arg_types[i], arg_values[i]); - } + AppendArgValue(arg_types[i], arg_values[i]); } stream_ << "}}"; // TODO(fmeawad): Add support for Flow Events. diff --git a/deps/v8/src/libplatform/tracing/trace-writer.h b/deps/v8/src/libplatform/tracing/trace-writer.h index 43d7cb6a9063f8..963fc6a64dc262 100644 --- a/deps/v8/src/libplatform/tracing/trace-writer.h +++ b/deps/v8/src/libplatform/tracing/trace-writer.h @@ -20,7 +20,6 @@ class JSONTraceWriter : public TraceWriter { private: void AppendArgValue(uint8_t type, TraceObject::ArgValue value); - void AppendArgValue(v8::ConvertableToTraceFormat*); std::ostream& stream_; bool append_comma_ = false; diff --git a/deps/v8/src/libplatform/tracing/tracing-controller.cc b/deps/v8/src/libplatform/tracing/tracing-controller.cc index c1a4057c0555b4..4d932143650862 100644 --- a/deps/v8/src/libplatform/tracing/tracing-controller.cc +++ b/deps/v8/src/libplatform/tracing/tracing-controller.cc @@ -51,15 +51,13 @@ uint64_t TracingController::AddTraceEvent( char phase, const uint8_t* category_enabled_flag, const char* name, const char* scope, uint64_t id, uint64_t bind_id, int num_args, const char** arg_names, const uint8_t* arg_types, - const uint64_t* arg_values, - std::unique_ptr* arg_convertables, - unsigned int flags) { + const uint64_t* arg_values, unsigned int flags) { uint64_t handle; TraceObject* trace_object = trace_buffer_->AddTraceEvent(&handle); if (trace_object) { trace_object->Initialize(phase, category_enabled_flag, name, scope, id, bind_id, num_args, arg_names, arg_types, - arg_values, arg_convertables, flags); + arg_values, flags); } return handle; } diff --git a/deps/v8/src/objects.h b/deps/v8/src/objects.h index fcc1f9457b4f07..1709cef15e8cd1 100644 --- a/deps/v8/src/objects.h +++ b/deps/v8/src/objects.h @@ -709,11 +709,11 @@ enum InstanceType { // interceptors. JS_SPECIAL_API_OBJECT_TYPE, // LAST_SPECIAL_RECEIVER_TYPE JS_VALUE_TYPE, // LAST_CUSTOM_ELEMENTS_RECEIVER - JS_MESSAGE_OBJECT_TYPE, - JS_DATE_TYPE, // Like JS_OBJECT_TYPE, but created from API function. JS_API_OBJECT_TYPE, JS_OBJECT_TYPE, + JS_MESSAGE_OBJECT_TYPE, + JS_DATE_TYPE, JS_ARGUMENTS_TYPE, JS_CONTEXT_EXTENSION_OBJECT_TYPE, JS_GENERATOR_OBJECT_TYPE, diff --git a/deps/v8/src/tracing/trace-event.h b/deps/v8/src/tracing/trace-event.h index 35d2e1507d3fb3..06f8990ec80e4f 100644 --- a/deps/v8/src/tracing/trace-event.h +++ b/deps/v8/src/tracing/trace-event.h @@ -6,7 +6,6 @@ #define SRC_TRACING_TRACE_EVENT_H_ #include -#include #include "base/trace_event/common/trace_event_common.h" #include "include/v8-platform.h" @@ -121,7 +120,8 @@ enum CategoryGroupEnabledFlags { // const uint8_t* arg_types, // const uint64_t* arg_values, // unsigned int flags) -#define TRACE_EVENT_API_ADD_TRACE_EVENT v8::internal::tracing::AddTraceEventImpl +#define TRACE_EVENT_API_ADD_TRACE_EVENT \ + v8::internal::tracing::TraceEventHelper::GetCurrentPlatform()->AddTraceEvent // Set the duration field of a COMPLETE trace event. // void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( @@ -454,28 +454,6 @@ class TraceStringWithCopy { const char* str_; }; -static V8_INLINE uint64_t AddTraceEventImpl( - char phase, const uint8_t* category_group_enabled, const char* name, - const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args, - const char** arg_names, const uint8_t* arg_types, - const uint64_t* arg_values, unsigned int flags) { - std::unique_ptr arg_convertables[2]; - if (num_args > 0 && arg_types[0] == TRACE_VALUE_TYPE_CONVERTABLE) { - arg_convertables[0].reset(reinterpret_cast( - static_cast(arg_values[0]))); - } - if (num_args > 1 && arg_types[1] == TRACE_VALUE_TYPE_CONVERTABLE) { - arg_convertables[1].reset(reinterpret_cast( - static_cast(arg_values[1]))); - } - DCHECK(num_args <= 2); - v8::Platform* platform = - v8::internal::tracing::TraceEventHelper::GetCurrentPlatform(); - return platform->AddTraceEvent(phase, category_group_enabled, name, scope, id, - bind_id, num_args, arg_names, arg_types, - arg_values, arg_convertables, flags); -} - // Define SetTraceValue for each allowed type. It stores the type and // value in the return arguments. This allows this API to avoid declaring any // structures so that it is portable to third_party libraries. @@ -516,19 +494,6 @@ INTERNAL_DECLARE_SET_TRACE_VALUE(const TraceStringWithCopy&, as_string, #undef INTERNAL_DECLARE_SET_TRACE_VALUE #undef INTERNAL_DECLARE_SET_TRACE_VALUE_INT -static V8_INLINE void SetTraceValue(ConvertableToTraceFormat* convertable_value, - unsigned char* type, uint64_t* value) { - *type = TRACE_VALUE_TYPE_CONVERTABLE; - *value = static_cast(reinterpret_cast(convertable_value)); -} - -template -static V8_INLINE typename std::enable_if< - std::is_convertible::value>::type -SetTraceValue(std::unique_ptr ptr, unsigned char* type, uint64_t* value) { - SetTraceValue(ptr.release(), type, value); -} - // These AddTraceEvent template // function is defined here instead of in the macro, because the arg_values // could be temporary objects, such as std::string. In order to store @@ -541,38 +506,36 @@ static V8_INLINE uint64_t AddTraceEvent(char phase, uint64_t id, uint64_t bind_id, unsigned int flags) { return TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_group_enabled, name, - scope, id, bind_id, kZeroNumArgs, - nullptr, nullptr, nullptr, flags); + scope, id, bind_id, kZeroNumArgs, NULL, + NULL, NULL, flags); } template static V8_INLINE uint64_t AddTraceEvent( char phase, const uint8_t* category_group_enabled, const char* name, const char* scope, uint64_t id, uint64_t bind_id, unsigned int flags, - const char* arg1_name, ARG1_TYPE&& arg1_val) { + const char* arg1_name, const ARG1_TYPE& arg1_val) { const int num_args = 1; - uint8_t arg_type; - uint64_t arg_value; - SetTraceValue(std::forward(arg1_val), &arg_type, &arg_value); + uint8_t arg_types[1]; + uint64_t arg_values[1]; + SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); return TRACE_EVENT_API_ADD_TRACE_EVENT( phase, category_group_enabled, name, scope, id, bind_id, num_args, - &arg1_name, &arg_type, &arg_value, flags); + &arg1_name, arg_types, arg_values, flags); } template static V8_INLINE uint64_t AddTraceEvent( char phase, const uint8_t* category_group_enabled, const char* name, const char* scope, uint64_t id, uint64_t bind_id, unsigned int flags, - const char* arg1_name, ARG1_TYPE&& arg1_val, const char* arg2_name, - ARG2_TYPE&& arg2_val) { + const char* arg1_name, const ARG1_TYPE& arg1_val, const char* arg2_name, + const ARG2_TYPE& arg2_val) { const int num_args = 2; const char* arg_names[2] = {arg1_name, arg2_name}; unsigned char arg_types[2]; uint64_t arg_values[2]; - SetTraceValue(std::forward(arg1_val), &arg_types[0], - &arg_values[0]); - SetTraceValue(std::forward(arg2_val), &arg_types[1], - &arg_values[1]); + SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); + SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); return TRACE_EVENT_API_ADD_TRACE_EVENT( phase, category_group_enabled, name, scope, id, bind_id, num_args, arg_names, arg_types, arg_values, flags); diff --git a/deps/v8/test/cctest/libplatform/test-tracing.cc b/deps/v8/test/cctest/libplatform/test-tracing.cc index 66fa0e05a52418..625711d846d394 100644 --- a/deps/v8/test/cctest/libplatform/test-tracing.cc +++ b/deps/v8/test/cctest/libplatform/test-tracing.cc @@ -35,8 +35,7 @@ TEST(TestTraceObject) { TraceObject trace_object; uint8_t category_enabled_flag = 41; trace_object.Initialize('X', &category_enabled_flag, "Test.Trace", - "Test.Scope", 42, 123, 0, nullptr, nullptr, nullptr, - nullptr, 0); + "Test.Scope", 42, 123, 0, NULL, NULL, NULL, 0); CHECK_EQ('X', trace_object.phase()); CHECK_EQ(category_enabled_flag, *trace_object.category_enabled_flag()); CHECK_EQ(std::string("Test.Trace"), std::string(trace_object.name())); @@ -45,19 +44,6 @@ TEST(TestTraceObject) { CHECK_EQ(0, trace_object.cpu_duration()); } -class ConvertableToTraceFormatMock : public v8::ConvertableToTraceFormat { - public: - explicit ConvertableToTraceFormatMock(int value) : value_(value) {} - void AppendAsTraceFormat(std::string* out) const override { - *out += "[" + std::to_string(value_) + "," + std::to_string(value_) + "]"; - } - - private: - int value_; - - DISALLOW_COPY_AND_ASSIGN(ConvertableToTraceFormatMock); -}; - class MockTraceWriter : public TraceWriter { public: void AppendTraceEvent(TraceObject* trace_event) override { @@ -89,8 +75,7 @@ TEST(TestTraceBufferRingBuffer) { TraceObject* trace_object = ring_buffer->AddTraceEvent(&handles[i]); CHECK_NOT_NULL(trace_object); trace_object->Initialize('X', &category_enabled_flag, names[i].c_str(), - "Test.Scope", 42, 123, 0, nullptr, nullptr, - nullptr, nullptr, 0); + "Test.Scope", 42, 123, 0, NULL, NULL, NULL, 0); trace_object = ring_buffer->GetEventByHandle(handles[i]); CHECK_NOT_NULL(trace_object); CHECK_EQ('X', trace_object->phase()); @@ -143,13 +128,13 @@ TEST(TestJSONTraceWriter) { TraceObject trace_object; trace_object.InitializeForTesting( 'X', tracing_controller.GetCategoryGroupEnabled("v8-cat"), "Test0", - v8::internal::tracing::kGlobalScope, 42, 123, 0, nullptr, nullptr, - nullptr, nullptr, TRACE_EVENT_FLAG_HAS_ID, 11, 22, 100, 50, 33, 44); + v8::internal::tracing::kGlobalScope, 42, 123, 0, NULL, NULL, NULL, + TRACE_EVENT_FLAG_HAS_ID, 11, 22, 100, 50, 33, 44); writer->AppendTraceEvent(&trace_object); trace_object.InitializeForTesting( 'Y', tracing_controller.GetCategoryGroupEnabled("v8-cat"), "Test1", - v8::internal::tracing::kGlobalScope, 43, 456, 0, nullptr, nullptr, - nullptr, nullptr, 0, 55, 66, 110, 55, 77, 88); + v8::internal::tracing::kGlobalScope, 43, 456, 0, NULL, NULL, NULL, 0, + 55, 66, 110, 55, 77, 88); writer->AppendTraceEvent(&trace_object); tracing_controller.StopTracing(); } @@ -279,14 +264,6 @@ TEST(TestTracingControllerMultipleArgsAndCopy) { mm = "CHANGED"; mmm = "CHANGED"; - TRACE_EVENT_INSTANT1("v8", "v8.Test", TRACE_EVENT_SCOPE_THREAD, "a1", - new ConvertableToTraceFormatMock(42)); - std::unique_ptr trace_event_arg( - new ConvertableToTraceFormatMock(42)); - TRACE_EVENT_INSTANT2("v8", "v8.Test", TRACE_EVENT_SCOPE_THREAD, "a1", - std::move(trace_event_arg), "a2", - new ConvertableToTraceFormatMock(123)); - tracing_controller.StopTracing(); } @@ -297,7 +274,7 @@ TEST(TestTracingControllerMultipleArgsAndCopy) { GetJSONStrings(all_names, trace_str, "\"name\"", "\"", "\""); GetJSONStrings(all_cats, trace_str, "\"cat\"", "\"", "\""); - CHECK_EQ(all_args.size(), 24); + CHECK_EQ(all_args.size(), 22); CHECK_EQ(all_args[0], "\"aa\":11"); CHECK_EQ(all_args[1], "\"bb\":22"); CHECK_EQ(all_args[2], "\"cc\":33"); @@ -326,8 +303,6 @@ TEST(TestTracingControllerMultipleArgsAndCopy) { CHECK_EQ(all_names[20], "INIT"); CHECK_EQ(all_names[21], "INIT"); CHECK_EQ(all_args[21], "\"mm1\":\"INIT\",\"mm2\":\"\\\"INIT\\\"\""); - CHECK_EQ(all_args[22], "\"a1\":[42,42]"); - CHECK_EQ(all_args[23], "\"a1\":[42,42],\"a2\":[123,123]"); i::V8::SetPlatformForTesting(old_platform); } diff --git a/deps/v8/test/cctest/test-api-interceptors.cc b/deps/v8/test/cctest/test-api-interceptors.cc index 572487976e97ff..4110cafbed3bcd 100644 --- a/deps/v8/test/cctest/test-api-interceptors.cc +++ b/deps/v8/test/cctest/test-api-interceptors.cc @@ -238,26 +238,6 @@ void CheckThisNamedPropertyHandler( .FromJust()); } -void CheckThisIndexedPropertyDefiner( - uint32_t index, const v8::PropertyDescriptor& desc, - const v8::PropertyCallbackInfo& info) { - CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyDefiner)); - ApiTestFuzzer::Fuzz(); - CHECK(info.This() - ->Equals(info.GetIsolate()->GetCurrentContext(), bottom) - .FromJust()); -} - -void CheckThisNamedPropertyDefiner( - Local property, const v8::PropertyDescriptor& desc, - const v8::PropertyCallbackInfo& info) { - CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyDefiner)); - ApiTestFuzzer::Fuzz(); - CHECK(info.This() - ->Equals(info.GetIsolate()->GetCurrentContext(), bottom) - .FromJust()); -} - void CheckThisIndexedPropertySetter( uint32_t index, Local value, const v8::PropertyCallbackInfo& info) { @@ -268,24 +248,6 @@ void CheckThisIndexedPropertySetter( .FromJust()); } -void CheckThisIndexedPropertyDescriptor( - uint32_t index, const v8::PropertyCallbackInfo& info) { - CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyDescriptor)); - ApiTestFuzzer::Fuzz(); - CHECK(info.This() - ->Equals(info.GetIsolate()->GetCurrentContext(), bottom) - .FromJust()); -} - -void CheckThisNamedPropertyDescriptor( - Local property, const v8::PropertyCallbackInfo& info) { - CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyDescriptor)); - ApiTestFuzzer::Fuzz(); - CHECK(info.This() - ->Equals(info.GetIsolate()->GetCurrentContext(), bottom) - .FromJust()); -} - void CheckThisNamedPropertySetter( Local property, Local value, const v8::PropertyCallbackInfo& info) { @@ -610,52 +572,6 @@ THREADED_TEST(SetterCallbackFunctionDeclarationInterceptorThrow) { CHECK_EQ(set_was_called, false); } -bool get_was_called_in_order = false; -bool define_was_called_in_order = false; - -namespace { - -void GetterCallbackOrder(Local property, - const v8::PropertyCallbackInfo& info) { - get_was_called_in_order = true; - CHECK_EQ(define_was_called_in_order, true); - info.GetReturnValue().Set(property); -} - -void DefinerCallbackOrder(Local property, - const v8::PropertyDescriptor& desc, - const v8::PropertyCallbackInfo& info) { - CHECK_EQ(get_was_called_in_order, false); // Define called before get. - define_was_called_in_order = true; -} - -} // namespace - -// Check that definer callback is called before getter callback. -THREADED_TEST(DefinerCallbackGetAndDefine) { - v8::HandleScope scope(CcTest::isolate()); - v8::Local templ = - v8::FunctionTemplate::New(CcTest::isolate()); - templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - GetterCallbackOrder, SetterCallback, 0, 0, 0, DefinerCallbackOrder)); - LocalContext env; - env->Global() - ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) - .ToLocalChecked() - ->NewInstance(env.local()) - .ToLocalChecked()) - .FromJust(); - - CHECK_EQ(get_was_called_in_order, false); - CHECK_EQ(define_was_called_in_order, false); - - v8_compile("Object.defineProperty(obj, 'x', {set: function() {return 17;}});") - ->Run(env.local()) - .ToLocalChecked(); - CHECK_EQ(get_was_called_in_order, true); - CHECK_EQ(define_was_called_in_order, true); -} - THREADED_TEST(InterceptorHasOwnProperty) { LocalContext context; v8::Isolate* isolate = context->GetIsolate(); @@ -1412,504 +1328,6 @@ THREADED_TEST(NamedPropertyHandlerGetter) { .FromJust()); } -namespace { -void NotInterceptingPropertyDefineCallback( - Local name, const v8::PropertyDescriptor& desc, - const v8::PropertyCallbackInfo& info) { - // Do not intercept by not calling info.GetReturnValue().Set(). -} - -void InterceptingPropertyDefineCallback( - Local name, const v8::PropertyDescriptor& desc, - const v8::PropertyCallbackInfo& info) { - // Intercept the callback by setting a non-empty handle - info.GetReturnValue().Set(name); -} - -void CheckDescriptorInDefineCallback( - Local name, const v8::PropertyDescriptor& desc, - const v8::PropertyCallbackInfo& info) { - CHECK(!desc.has_writable()); - CHECK(!desc.has_value()); - CHECK(!desc.has_enumerable()); - CHECK(desc.has_configurable()); - CHECK(!desc.configurable()); - CHECK(desc.has_get()); - CHECK(desc.get()->IsFunction()); - CHECK(desc.has_set()); - CHECK(desc.set()->IsUndefined()); - // intercept the callback by setting a non-empty handle - info.GetReturnValue().Set(name); -} -} // namespace - -THREADED_TEST(PropertyDefinerCallback) { - v8::HandleScope scope(CcTest::isolate()); - LocalContext env; - - { // Intercept defineProperty() - v8::Local templ = - v8::FunctionTemplate::New(CcTest::isolate()); - templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, NotInterceptingPropertyDefineCallback)); - env->Global() - ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) - .ToLocalChecked() - ->NewInstance(env.local()) - .ToLocalChecked()) - .FromJust(); - const char* code = - "obj.x = 17; " - "Object.defineProperty(obj, 'x', {value: 42});" - "obj.x;"; - CHECK_EQ(42, v8_compile(code) - ->Run(env.local()) - .ToLocalChecked() - ->Int32Value(env.local()) - .FromJust()); - } - - { // Intercept defineProperty() for correct accessor descriptor - v8::Local templ = - v8::FunctionTemplate::New(CcTest::isolate()); - templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, CheckDescriptorInDefineCallback)); - env->Global() - ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) - .ToLocalChecked() - ->NewInstance(env.local()) - .ToLocalChecked()) - .FromJust(); - const char* code = - "obj.x = 17; " - "Object.defineProperty(obj, 'x', {" - "get: function(){ return 42; }, " - "set: undefined," - "configurable: 0" - "});" - "obj.x;"; - CHECK_EQ(17, v8_compile(code) - ->Run(env.local()) - .ToLocalChecked() - ->Int32Value(env.local()) - .FromJust()); - } - - { // Do not intercept defineProperty() - v8::Local templ2 = - v8::FunctionTemplate::New(CcTest::isolate()); - templ2->InstanceTemplate()->SetHandler( - v8::NamedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, InterceptingPropertyDefineCallback)); - env->Global() - ->Set(env.local(), v8_str("obj"), templ2->GetFunction(env.local()) - .ToLocalChecked() - ->NewInstance(env.local()) - .ToLocalChecked()) - .FromJust(); - - const char* code = - "obj.x = 17; " - "Object.defineProperty(obj, 'x', {value: 42});" - "obj.x;"; - CHECK_EQ(17, v8_compile(code) - ->Run(env.local()) - .ToLocalChecked() - ->Int32Value(env.local()) - .FromJust()); - } -} - -namespace { -void NotInterceptingPropertyDefineCallbackIndexed( - uint32_t index, const v8::PropertyDescriptor& desc, - const v8::PropertyCallbackInfo& info) { - // Do not intercept by not calling info.GetReturnValue().Set() -} - -void InterceptingPropertyDefineCallbackIndexed( - uint32_t index, const v8::PropertyDescriptor& desc, - const v8::PropertyCallbackInfo& info) { - // intercept the callback by setting a non-empty handle - info.GetReturnValue().Set(index); -} - -void CheckDescriptorInDefineCallbackIndexed( - uint32_t index, const v8::PropertyDescriptor& desc, - const v8::PropertyCallbackInfo& info) { - CHECK(!desc.has_writable()); - CHECK(!desc.has_value()); - CHECK(desc.has_enumerable()); - CHECK(desc.enumerable()); - CHECK(!desc.has_configurable()); - CHECK(desc.has_get()); - CHECK(desc.get()->IsFunction()); - CHECK(desc.has_set()); - CHECK(desc.set()->IsUndefined()); - // intercept the callback by setting a non-empty handle - info.GetReturnValue().Set(index); -} -} // namespace - -THREADED_TEST(PropertyDefinerCallbackIndexed) { - v8::HandleScope scope(CcTest::isolate()); - LocalContext env; - - { // Intercept defineProperty() - v8::Local templ = - v8::FunctionTemplate::New(CcTest::isolate()); - templ->InstanceTemplate()->SetHandler( - v8::IndexedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, NotInterceptingPropertyDefineCallbackIndexed)); - env->Global() - ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) - .ToLocalChecked() - ->NewInstance(env.local()) - .ToLocalChecked()) - .FromJust(); - const char* code = - "obj[2] = 17; " - "Object.defineProperty(obj, 2, {value: 42});" - "obj[2];"; - CHECK_EQ(42, v8_compile(code) - ->Run(env.local()) - .ToLocalChecked() - ->Int32Value(env.local()) - .FromJust()); - } - - { // Intercept defineProperty() for correct accessor descriptor - v8::Local templ = - v8::FunctionTemplate::New(CcTest::isolate()); - templ->InstanceTemplate()->SetHandler( - v8::IndexedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, CheckDescriptorInDefineCallbackIndexed)); - env->Global() - ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) - .ToLocalChecked() - ->NewInstance(env.local()) - .ToLocalChecked()) - .FromJust(); - const char* code = - "obj[2] = 17; " - "Object.defineProperty(obj, 2, {" - "get: function(){ return 42; }, " - "set: undefined," - "enumerable: true" - "});" - "obj[2];"; - CHECK_EQ(17, v8_compile(code) - ->Run(env.local()) - .ToLocalChecked() - ->Int32Value(env.local()) - .FromJust()); - } - - { // Do not intercept defineProperty() - v8::Local templ2 = - v8::FunctionTemplate::New(CcTest::isolate()); - templ2->InstanceTemplate()->SetHandler( - v8::IndexedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, InterceptingPropertyDefineCallbackIndexed)); - env->Global() - ->Set(env.local(), v8_str("obj"), templ2->GetFunction(env.local()) - .ToLocalChecked() - ->NewInstance(env.local()) - .ToLocalChecked()) - .FromJust(); - - const char* code = - "obj[2] = 17; " - "Object.defineProperty(obj, 2, {value: 42});" - "obj[2];"; - CHECK_EQ(17, v8_compile(code) - ->Run(env.local()) - .ToLocalChecked() - ->Int32Value(env.local()) - .FromJust()); - } -} - -// Test that freeze() is intercepted. -THREADED_TEST(PropertyDefinerCallbackForFreeze) { - v8::HandleScope scope(CcTest::isolate()); - LocalContext env; - v8::Local templ = - v8::FunctionTemplate::New(CcTest::isolate()); - templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, InterceptingPropertyDefineCallback)); - env->Global() - ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) - .ToLocalChecked() - ->NewInstance(env.local()) - .ToLocalChecked()) - .FromJust(); - const char* code = - "obj.x = 17; " - "Object.freeze(obj.x); " - "Object.isFrozen(obj.x);"; - - CHECK(v8_compile(code) - ->Run(env.local()) - .ToLocalChecked() - ->BooleanValue(env.local()) - .FromJust()); -} - -// Check that the descriptor passed to the callback is enumerable. -namespace { -void CheckEnumerablePropertyDefineCallback( - Local name, const v8::PropertyDescriptor& desc, - const v8::PropertyCallbackInfo& info) { - CHECK(desc.has_value()); - CHECK_EQ(42, desc.value() - ->Int32Value(info.GetIsolate()->GetCurrentContext()) - .FromJust()); - CHECK(desc.has_enumerable()); - CHECK(desc.enumerable()); - CHECK(!desc.has_writable()); - - // intercept the callback by setting a non-empty handle - info.GetReturnValue().Set(name); -} -} // namespace -THREADED_TEST(PropertyDefinerCallbackEnumerable) { - v8::HandleScope scope(CcTest::isolate()); - LocalContext env; - v8::Local templ = - v8::FunctionTemplate::New(CcTest::isolate()); - templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, CheckEnumerablePropertyDefineCallback)); - env->Global() - ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) - .ToLocalChecked() - ->NewInstance(env.local()) - .ToLocalChecked()) - .FromJust(); - const char* code = - "obj.x = 17; " - "Object.defineProperty(obj, 'x', {value: 42, enumerable: true});" - "obj.x;"; - CHECK_EQ(17, v8_compile(code) - ->Run(env.local()) - .ToLocalChecked() - ->Int32Value(env.local()) - .FromJust()); -} - -// Check that the descriptor passed to the callback is configurable. -namespace { -void CheckConfigurablePropertyDefineCallback( - Local name, const v8::PropertyDescriptor& desc, - const v8::PropertyCallbackInfo& info) { - CHECK(desc.has_value()); - CHECK_EQ(42, desc.value() - ->Int32Value(info.GetIsolate()->GetCurrentContext()) - .FromJust()); - CHECK(desc.has_configurable()); - CHECK(desc.configurable()); - - // intercept the callback by setting a non-empty handle - info.GetReturnValue().Set(name); -} -} // namespace -THREADED_TEST(PropertyDefinerCallbackConfigurable) { - v8::HandleScope scope(CcTest::isolate()); - LocalContext env; - v8::Local templ = - v8::FunctionTemplate::New(CcTest::isolate()); - templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, CheckConfigurablePropertyDefineCallback)); - env->Global() - ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) - .ToLocalChecked() - ->NewInstance(env.local()) - .ToLocalChecked()) - .FromJust(); - const char* code = - "obj.x = 17; " - "Object.defineProperty(obj, 'x', {value: 42, configurable: true});" - "obj.x;"; - CHECK_EQ(17, v8_compile(code) - ->Run(env.local()) - .ToLocalChecked() - ->Int32Value(env.local()) - .FromJust()); -} - -// Check that the descriptor passed to the callback is writable. -namespace { -void CheckWritablePropertyDefineCallback( - Local name, const v8::PropertyDescriptor& desc, - const v8::PropertyCallbackInfo& info) { - CHECK(desc.has_writable()); - CHECK(desc.writable()); - - // intercept the callback by setting a non-empty handle - info.GetReturnValue().Set(name); -} -} // namespace -THREADED_TEST(PropertyDefinerCallbackWritable) { - v8::HandleScope scope(CcTest::isolate()); - LocalContext env; - v8::Local templ = - v8::FunctionTemplate::New(CcTest::isolate()); - templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, CheckWritablePropertyDefineCallback)); - env->Global() - ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) - .ToLocalChecked() - ->NewInstance(env.local()) - .ToLocalChecked()) - .FromJust(); - const char* code = - "obj.x = 17; " - "Object.defineProperty(obj, 'x', {value: 42, writable: true});" - "obj.x;"; - CHECK_EQ(17, v8_compile(code) - ->Run(env.local()) - .ToLocalChecked() - ->Int32Value(env.local()) - .FromJust()); -} - -// Check that the descriptor passed to the callback has a getter. -namespace { -void CheckGetterPropertyDefineCallback( - Local name, const v8::PropertyDescriptor& desc, - const v8::PropertyCallbackInfo& info) { - CHECK(desc.has_get()); - CHECK(!desc.has_set()); - // intercept the callback by setting a non-empty handle - info.GetReturnValue().Set(name); -} -} // namespace -THREADED_TEST(PropertyDefinerCallbackWithGetter) { - v8::HandleScope scope(CcTest::isolate()); - LocalContext env; - v8::Local templ = - v8::FunctionTemplate::New(CcTest::isolate()); - templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, CheckGetterPropertyDefineCallback)); - env->Global() - ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) - .ToLocalChecked() - ->NewInstance(env.local()) - .ToLocalChecked()) - .FromJust(); - const char* code = - "obj.x = 17;" - "Object.defineProperty(obj, 'x', {get: function() {return 42;}});" - "obj.x;"; - CHECK_EQ(17, v8_compile(code) - ->Run(env.local()) - .ToLocalChecked() - ->Int32Value(env.local()) - .FromJust()); -} - -// Check that the descriptor passed to the callback has a setter. -namespace { -void CheckSetterPropertyDefineCallback( - Local name, const v8::PropertyDescriptor& desc, - const v8::PropertyCallbackInfo& info) { - CHECK(desc.has_set()); - CHECK(!desc.has_get()); - // intercept the callback by setting a non-empty handle - info.GetReturnValue().Set(name); -} -} // namespace -THREADED_TEST(PropertyDefinerCallbackWithSetter) { - v8::HandleScope scope(CcTest::isolate()); - LocalContext env; - v8::Local templ = - v8::FunctionTemplate::New(CcTest::isolate()); - templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, 0, 0, 0, CheckSetterPropertyDefineCallback)); - env->Global() - ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) - .ToLocalChecked() - ->NewInstance(env.local()) - .ToLocalChecked()) - .FromJust(); - const char* code = - "Object.defineProperty(obj, 'x', {set: function() {return 42;}});" - "obj.x = 17;"; - CHECK_EQ(17, v8_compile(code) - ->Run(env.local()) - .ToLocalChecked() - ->Int32Value(env.local()) - .FromJust()); -} - -namespace { -void EmptyPropertyDescriptorCallback( - Local name, const v8::PropertyCallbackInfo& info) { - // Do not intercept by not calling info.GetReturnValue().Set(). -} - -void InterceptingPropertyDescriptorCallback( - Local name, const v8::PropertyCallbackInfo& info) { - // Intercept the callback by setting a different descriptor. - const char* code = - "var desc = {value: 42};" - "desc;"; - Local descriptor = v8_compile(code) - ->Run(info.GetIsolate()->GetCurrentContext()) - .ToLocalChecked(); - info.GetReturnValue().Set(descriptor); -} -} // namespace - -THREADED_TEST(PropertyDescriptorCallback) { - v8::HandleScope scope(CcTest::isolate()); - LocalContext env; - - { // Normal behavior of getOwnPropertyDescriptor() with empty callback. - v8::Local templ = - v8::FunctionTemplate::New(CcTest::isolate()); - templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, EmptyPropertyDescriptorCallback, 0, 0, 0)); - env->Global() - ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) - .ToLocalChecked() - ->NewInstance(env.local()) - .ToLocalChecked()) - .FromJust(); - const char* code = - "obj.x = 17; " - "var desc = Object.getOwnPropertyDescriptor(obj, 'x');" - "desc.value;"; - CHECK_EQ(17, v8_compile(code) - ->Run(env.local()) - .ToLocalChecked() - ->Int32Value(env.local()) - .FromJust()); - } - - { // Intercept getOwnPropertyDescriptor(). - v8::Local templ = - v8::FunctionTemplate::New(CcTest::isolate()); - templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - 0, 0, InterceptingPropertyDescriptorCallback, 0, 0, 0)); - env->Global() - ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) - .ToLocalChecked() - ->NewInstance(env.local()) - .ToLocalChecked()) - .FromJust(); - const char* code = - "obj.x = 17; " - "var desc = Object.getOwnPropertyDescriptor(obj, 'x');" - "desc.value;"; - CHECK_EQ(42, v8_compile(code) - ->Run(env.local()) - .ToLocalChecked() - ->Int32Value(env.local()) - .FromJust()); - } -} - int echo_indexed_call_count = 0; @@ -1999,63 +1417,6 @@ THREADED_TEST(PropertyHandlerInPrototype) { CompileRun("for (var p in obj) ;"); } -TEST(PropertyHandlerInPrototypeWithDefine) { - LocalContext env; - v8::Isolate* isolate = env->GetIsolate(); - v8::HandleScope scope(isolate); - - v8::Local templ = v8::FunctionTemplate::New(isolate); - templ->InstanceTemplate()->SetHandler(v8::IndexedPropertyHandlerConfiguration( - CheckThisIndexedPropertyHandler, CheckThisIndexedPropertySetter, - CheckThisIndexedPropertyDescriptor, CheckThisIndexedPropertyDeleter, - CheckThisIndexedPropertyEnumerator, CheckThisIndexedPropertyDefiner)); - - templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( - CheckThisNamedPropertyHandler, CheckThisNamedPropertySetter, - CheckThisNamedPropertyDescriptor, CheckThisNamedPropertyDeleter, - CheckThisNamedPropertyEnumerator, CheckThisNamedPropertyDefiner)); - - bottom = templ->GetFunction(env.local()) - .ToLocalChecked() - ->NewInstance(env.local()) - .ToLocalChecked(); - Local top = templ->GetFunction(env.local()) - .ToLocalChecked() - ->NewInstance(env.local()) - .ToLocalChecked(); - Local middle = templ->GetFunction(env.local()) - .ToLocalChecked() - ->NewInstance(env.local()) - .ToLocalChecked(); - - bottom->SetPrototype(env.local(), middle).FromJust(); - middle->SetPrototype(env.local(), top).FromJust(); - env->Global()->Set(env.local(), v8_str("obj"), bottom).FromJust(); - - // Indexed and named get. - CompileRun("obj[0]"); - CompileRun("obj.x"); - - // Indexed and named set. - CompileRun("obj[1] = 42"); - CompileRun("obj.y = 42"); - - // Indexed and named deleter. - CompileRun("delete obj[0]"); - CompileRun("delete obj.x"); - - // Enumerators. - CompileRun("for (var p in obj) ;"); - - // Indexed and named definer. - CompileRun("Object.defineProperty(obj, 2, {});"); - CompileRun("Object.defineProperty(obj, 'z', {});"); - - // Indexed and named propertyDescriptor. - CompileRun("Object.getOwnPropertyDescriptor(obj, 2);"); - CompileRun("Object.getOwnPropertyDescriptor(obj, 'z');"); -} - bool is_bootstrapping = false; static void PrePropertyHandlerGet( diff --git a/deps/v8/test/cctest/test-trace-event.cc b/deps/v8/test/cctest/test-trace-event.cc index 88f295f30126f6..67a72c3630c1c5 100644 --- a/deps/v8/test/cctest/test-trace-event.cc +++ b/deps/v8/test/cctest/test-trace-event.cc @@ -72,13 +72,11 @@ class MockTracingPlatform : public v8::Platform { void PerformDelayedTask() {} using Platform::AddTraceEvent; - uint64_t AddTraceEvent( - char phase, const uint8_t* category_enabled_flag, const char* name, - const char* scope, uint64_t id, uint64_t bind_id, int num_args, - const char** arg_names, const uint8_t* arg_types, - const uint64_t* arg_values, - std::unique_ptr* arg_convertables, - unsigned int flags) override { + uint64_t AddTraceEvent(char phase, const uint8_t* category_enabled_flag, + const char* name, const char* scope, uint64_t id, + uint64_t bind_id, int num_args, const char** arg_names, + const uint8_t* arg_types, const uint64_t* arg_values, + unsigned int flags) override { MockTraceObject* to = new MockTraceObject(phase, std::string(name), id, bind_id, num_args, flags); trace_object_list_.Add(to);