diff --git a/deps/chakrashim/chakrashim.gyp b/deps/chakrashim/chakrashim.gyp index 5c0da9d958d..a0aa26549ae 100644 --- a/deps/chakrashim/chakrashim.gyp +++ b/deps/chakrashim/chakrashim.gyp @@ -118,6 +118,7 @@ 'src/v8objecttemplate.cc', 'src/v8persistent.cc', 'src/v8private.cc', + 'src/v8promise.cc', 'src/v8propertydescriptor.cc', 'src/v8proxy.cc', 'src/v8script.cc', @@ -126,6 +127,7 @@ 'src/v8stacktrace.cc', 'src/v8string.cc', 'src/v8stringobject.cc', + 'src/v8symbol.cc', 'src/v8template.cc', 'src/v8trycatch.cc', 'src/v8typedarray.cc', diff --git a/deps/chakrashim/include/v8-platform.h b/deps/chakrashim/include/v8-platform.h index 8127e0a5f2c..59bb0be7cd3 100644 --- a/deps/chakrashim/include/v8-platform.h +++ b/deps/chakrashim/include/v8-platform.h @@ -29,6 +29,8 @@ #define V8_V8_PLATFORM_H_ #include +#include +#include namespace v8 { @@ -40,6 +42,22 @@ class Task { virtual void Run() = 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; +}; + class Platform { public: enum ExpectedRuntime { @@ -91,6 +109,25 @@ 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/chakrashim/include/v8.h b/deps/chakrashim/include/v8.h index 2432a39c5eb..fa1542cb09d 100644 --- a/deps/chakrashim/include/v8.h +++ b/deps/chakrashim/include/v8.h @@ -314,6 +314,7 @@ class Local { friend class StackTrace; friend class String; friend class StringObject; + friend class Symbol; friend class Utils; friend class TryCatch; friend class UnboundScript; @@ -1087,6 +1088,7 @@ class V8_EXPORT Boolean : public Primitive { public: bool Value() const; static Handle New(Isolate* isolate, bool value); + static Boolean* Cast(v8::Value* obj); private: friend class BooleanObject; @@ -1241,6 +1243,18 @@ class V8_EXPORT String : public Name { }; }; +class V8_EXPORT Symbol : public Name { + public: + Local Name() const; + static Local New(Isolate* isolate, + Local name = Local()); + static Symbol* Cast(Value* obj); + + private: + static Local From(Local name); + Symbol(); +}; + class V8_EXPORT Number : public Primitive { public: double Value() const; @@ -1682,6 +1696,11 @@ class V8_EXPORT Function : public Object { class V8_EXPORT Promise : public Object { public: + enum PromiseState { kPending, kFulfilled, kRejected }; + + Local Result(); + PromiseState State(); + class V8_EXPORT Resolver : public Object { public: static Local New(Isolate* isolate); @@ -2476,6 +2495,8 @@ class Maybe { bool IsNothing() const { return !has_value; } bool IsJust() const { return has_value; } + T ToChecked() const { return FromJust(); } + bool To(T* out) const { if (V8_LIKELY(IsJust())) *out = value; return IsJust(); diff --git a/deps/chakrashim/src/v8boolean.cc b/deps/chakrashim/src/v8boolean.cc index a2b94471fe5..77411baa749 100644 --- a/deps/chakrashim/src/v8boolean.cc +++ b/deps/chakrashim/src/v8boolean.cc @@ -34,4 +34,9 @@ Handle Boolean::New(Isolate* isolate, bool value) { return From(value); } +Boolean* Boolean::Cast(v8::Value* obj) { + CHAKRA_ASSERT(obj->IsBoolean()); + return static_cast(obj); +} + } // namespace v8 diff --git a/deps/chakrashim/src/v8promise.cc b/deps/chakrashim/src/v8promise.cc new file mode 100644 index 00000000000..3fa76a9379d --- /dev/null +++ b/deps/chakrashim/src/v8promise.cc @@ -0,0 +1,41 @@ +// Copyright Microsoft. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and / or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + +#include "v8chakra.h" +#include "jsrtutils.h" + +namespace v8 { + +Promise::Promise() { } + +Local Promise::Result() { + return Local(); +} + +Promise::PromiseState Promise::State() { + return PromiseState::kFulfilled; +} + +Promise* Promise::Cast(Value* obj) { + CHAKRA_ASSERT(obj->IsPromise()); + return static_cast(obj); +} + +} // namespace v8 diff --git a/deps/chakrashim/src/v8symbol.cc b/deps/chakrashim/src/v8symbol.cc new file mode 100644 index 00000000000..b142e09efed --- /dev/null +++ b/deps/chakrashim/src/v8symbol.cc @@ -0,0 +1,52 @@ +// Copyright Microsoft. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and / or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + +#include "v8chakra.h" +#include "jsrtutils.h" + +namespace v8 { + +Symbol::Symbol() { } + +Local Symbol::New(Isolate* isolate, Local name) { + return Local::New(isolate, From(name)); +} + +Local Symbol::From(Local name) { + JsValueRef sym; + JsValueRef description = (JsValueRef)*name; + + if (JsCreateSymbol(description, &sym) != JsNoError) { + return Local(); + } + + return Local::New(static_cast(sym)); +} + +Symbol* Symbol::Cast(Value* obj) { + CHAKRA_ASSERT(obj->IsSymbol()); + return static_cast(obj); +} + +Local Symbol::Name() const { + return Local(); +} + +} // namespace v8 diff --git a/deps/chakrashim/src/v8typedarray.cc b/deps/chakrashim/src/v8typedarray.cc index 937aabe8a1d..8e982cd4865 100644 --- a/deps/chakrashim/src/v8typedarray.cc +++ b/deps/chakrashim/src/v8typedarray.cc @@ -80,6 +80,11 @@ size_t TypedArray::Length() { return result; } +TypedArray* TypedArray::Cast(v8::Value* obj) { + CHAKRA_ASSERT(obj->IsTypedArray()); + return static_cast(obj); +} + JsErrorCode Utils::NewTypedArray(ContextShim::GlobalType constructorIndex, Handle array_buffer, size_t byte_offset, size_t length,