ensure maybe results are checked in v8.h

also some drive-by handlescope fixes in api.cc

R=svenpanne@chromium.org

BUG=

Review URL: https://codereview.chromium.org/1040043002

Cr-Commit-Position: refs/heads/master@{#27510}
This commit is contained in:
dcarney 2015-03-30 02:15:54 -07:00 committed by Commit bot
parent 8dad78cdbd
commit f303b81bde
2 changed files with 186 additions and 151 deletions

View File

@ -1118,8 +1118,8 @@ class V8_EXPORT Script {
"Use maybe version", "Use maybe version",
Local<Script> Compile(Handle<String> source, Local<Script> Compile(Handle<String> source,
ScriptOrigin* origin = nullptr)); ScriptOrigin* origin = nullptr));
static MaybeLocal<Script> Compile(Local<Context> context, static V8_WARN_UNUSED_RESULT MaybeLocal<Script> Compile(
Handle<String> source, Local<Context> context, Handle<String> source,
ScriptOrigin* origin = nullptr); ScriptOrigin* origin = nullptr);
static Local<Script> V8_DEPRECATE_SOON("Use maybe version", static Local<Script> V8_DEPRECATE_SOON("Use maybe version",
@ -1132,7 +1132,7 @@ class V8_EXPORT Script {
* UnboundScript::BindToCurrentContext()). * UnboundScript::BindToCurrentContext()).
*/ */
V8_DEPRECATE_SOON("Use maybe version", Local<Value> Run()); V8_DEPRECATE_SOON("Use maybe version", Local<Value> Run());
MaybeLocal<Value> Run(Local<Context> context); V8_WARN_UNUSED_RESULT MaybeLocal<Value> Run(Local<Context> context);
/** /**
* Returns the corresponding context-unbound script. * Returns the corresponding context-unbound script.
@ -1324,7 +1324,7 @@ class V8_EXPORT ScriptCompiler {
Local<UnboundScript> CompileUnbound( Local<UnboundScript> CompileUnbound(
Isolate* isolate, Source* source, Isolate* isolate, Source* source,
CompileOptions options = kNoCompileOptions)); CompileOptions options = kNoCompileOptions));
static MaybeLocal<UnboundScript> CompileUnboundScript( static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundScript(
Isolate* isolate, Source* source, Isolate* isolate, Source* source,
CompileOptions options = kNoCompileOptions); CompileOptions options = kNoCompileOptions);
@ -1343,7 +1343,8 @@ class V8_EXPORT ScriptCompiler {
"Use maybe version", "Use maybe version",
Local<Script> Compile(Isolate* isolate, Source* source, Local<Script> Compile(Isolate* isolate, Source* source,
CompileOptions options = kNoCompileOptions)); CompileOptions options = kNoCompileOptions));
static MaybeLocal<Script> Compile(Local<Context> context, Source* source, static V8_WARN_UNUSED_RESULT MaybeLocal<Script> Compile(
Local<Context> context, Source* source,
CompileOptions options = kNoCompileOptions); CompileOptions options = kNoCompileOptions);
/** /**
@ -1373,10 +1374,9 @@ class V8_EXPORT ScriptCompiler {
Local<Script> Compile(Isolate* isolate, StreamedSource* source, Local<Script> Compile(Isolate* isolate, StreamedSource* source,
Handle<String> full_source_string, Handle<String> full_source_string,
const ScriptOrigin& origin)); const ScriptOrigin& origin));
static MaybeLocal<Script> Compile(Local<Context> context, static V8_WARN_UNUSED_RESULT MaybeLocal<Script> Compile(
StreamedSource* source, Local<Context> context, StreamedSource* source,
Handle<String> full_source_string, Handle<String> full_source_string, const ScriptOrigin& origin);
const ScriptOrigin& origin);
/** /**
* Return a version tag for CachedData for the current V8 version & flags. * Return a version tag for CachedData for the current V8 version & flags.
@ -1410,7 +1410,7 @@ class V8_EXPORT ScriptCompiler {
"Use maybe version", "Use maybe version",
Local<Script> CompileModule(Isolate* isolate, Source* source, Local<Script> CompileModule(Isolate* isolate, Source* source,
CompileOptions options = kNoCompileOptions)); CompileOptions options = kNoCompileOptions));
static MaybeLocal<Script> CompileModule( static V8_WARN_UNUSED_RESULT MaybeLocal<Script> CompileModule(
Local<Context> context, Source* source, Local<Context> context, Source* source,
CompileOptions options = kNoCompileOptions); CompileOptions options = kNoCompileOptions);
@ -1431,13 +1431,13 @@ class V8_EXPORT ScriptCompiler {
Local<String> arguments[], Local<String> arguments[],
size_t context_extension_count, size_t context_extension_count,
Local<Object> context_extensions[])); Local<Object> context_extensions[]));
static MaybeLocal<Function> CompileFunctionInContext( static V8_WARN_UNUSED_RESULT MaybeLocal<Function> CompileFunctionInContext(
Local<Context> context, Source* source, size_t arguments_count, Local<Context> context, Source* source, size_t arguments_count,
Local<String> arguments[], size_t context_extension_count, Local<String> arguments[], size_t context_extension_count,
Local<Object> context_extensions[]); Local<Object> context_extensions[]);
private: private:
static MaybeLocal<UnboundScript> CompileUnboundInternal( static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundInternal(
Isolate* isolate, Source* source, CompileOptions options, bool is_module); Isolate* isolate, Source* source, CompileOptions options, bool is_module);
}; };
@ -1450,7 +1450,8 @@ class V8_EXPORT Message {
Local<String> Get() const; Local<String> Get() const;
V8_DEPRECATE_SOON("Use maybe version", Local<String> GetSourceLine()) const; V8_DEPRECATE_SOON("Use maybe version", Local<String> GetSourceLine()) const;
MaybeLocal<String> GetSourceLine(Local<Context> context) const; V8_WARN_UNUSED_RESULT MaybeLocal<String> GetSourceLine(
Local<Context> context) const;
/** /**
* Returns the origin for the script from where the function causing the * Returns the origin for the script from where the function causing the
@ -1475,7 +1476,7 @@ class V8_EXPORT Message {
* Returns the number, 1-based, of the line where the error occurred. * Returns the number, 1-based, of the line where the error occurred.
*/ */
V8_DEPRECATE_SOON("Use maybe version", int GetLineNumber()) const; V8_DEPRECATE_SOON("Use maybe version", int GetLineNumber()) const;
Maybe<int> GetLineNumber(Local<Context> context) const; V8_WARN_UNUSED_RESULT Maybe<int> GetLineNumber(Local<Context> context) const;
/** /**
* Returns the index within the script of the first character where * Returns the index within the script of the first character where
@ -1494,14 +1495,14 @@ class V8_EXPORT Message {
* the error occurred. * the error occurred.
*/ */
V8_DEPRECATE_SOON("Use maybe version", int GetStartColumn()) const; V8_DEPRECATE_SOON("Use maybe version", int GetStartColumn()) const;
Maybe<int> GetStartColumn(Local<Context> context) const; V8_WARN_UNUSED_RESULT Maybe<int> GetStartColumn(Local<Context> context) const;
/** /**
* Returns the index within the line of the last character where * Returns the index within the line of the last character where
* the error occurred. * the error occurred.
*/ */
V8_DEPRECATE_SOON("Use maybe version", int GetEndColumn()) const; V8_DEPRECATE_SOON("Use maybe version", int GetEndColumn()) const;
Maybe<int> GetEndColumn(Local<Context> context) const; V8_WARN_UNUSED_RESULT Maybe<int> GetEndColumn(Local<Context> context) const;
/** /**
* Passes on the value set by the embedder when it fed the script from which * Passes on the value set by the embedder when it fed the script from which
@ -1670,7 +1671,8 @@ class V8_EXPORT JSON {
*/ */
static V8_DEPRECATE_SOON("Use maybe version", static V8_DEPRECATE_SOON("Use maybe version",
Local<Value> Parse(Local<String> json_string)); Local<Value> Parse(Local<String> json_string));
static MaybeLocal<Value> Parse(Isolate* isolate, Local<String> json_string); static V8_WARN_UNUSED_RESULT MaybeLocal<Value> Parse(
Isolate* isolate, Local<String> json_string);
}; };
@ -1950,14 +1952,21 @@ class V8_EXPORT Value : public Data {
*/ */
bool IsDataView() const; bool IsDataView() const;
MaybeLocal<Boolean> ToBoolean(Local<Context> context) const; V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(
MaybeLocal<Number> ToNumber(Local<Context> context) const; Local<Context> context) const;
MaybeLocal<String> ToString(Local<Context> context) const; V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber(
MaybeLocal<String> ToDetailString(Local<Context> context) const; Local<Context> context) const;
MaybeLocal<Object> ToObject(Local<Context> context) const; V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString(
MaybeLocal<Integer> ToInteger(Local<Context> context) const; Local<Context> context) const;
MaybeLocal<Uint32> ToUint32(Local<Context> context) const; V8_WARN_UNUSED_RESULT MaybeLocal<String> ToDetailString(
MaybeLocal<Int32> ToInt32(Local<Context> context) const; Local<Context> context) const;
V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject(
Local<Context> context) const;
V8_WARN_UNUSED_RESULT MaybeLocal<Integer> ToInteger(
Local<Context> context) const;
V8_WARN_UNUSED_RESULT MaybeLocal<Uint32> ToUint32(
Local<Context> context) const;
V8_WARN_UNUSED_RESULT MaybeLocal<Int32> ToInt32(Local<Context> context) const;
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
Local<Boolean> ToBoolean(Isolate* isolate)) const; Local<Boolean> ToBoolean(Isolate* isolate)) const;
@ -1993,13 +2002,16 @@ class V8_EXPORT Value : public Data {
* Returns an empty handle if the conversion fails. * Returns an empty handle if the conversion fails.
*/ */
V8_DEPRECATE_SOON("Use maybe version", Local<Uint32> ToArrayIndex()) const; V8_DEPRECATE_SOON("Use maybe version", Local<Uint32> ToArrayIndex()) const;
MaybeLocal<Uint32> ToArrayIndex(Local<Context> context) const; V8_WARN_UNUSED_RESULT MaybeLocal<Uint32> ToArrayIndex(
Local<Context> context) const;
Maybe<bool> BooleanValue(Local<Context> context) const; V8_WARN_UNUSED_RESULT Maybe<bool> BooleanValue(Local<Context> context) const;
Maybe<double> NumberValue(Local<Context> context) const; V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
Maybe<int64_t> IntegerValue(Local<Context> context) const; V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
Maybe<uint32_t> Uint32Value(Local<Context> context) const; Local<Context> context) const;
Maybe<int32_t> Int32Value(Local<Context> context) const; V8_WARN_UNUSED_RESULT Maybe<uint32_t> Uint32Value(
Local<Context> context) const;
V8_WARN_UNUSED_RESULT Maybe<int32_t> Int32Value(Local<Context> context) const;
V8_DEPRECATE_SOON("Use maybe version", bool BooleanValue()) const; V8_DEPRECATE_SOON("Use maybe version", bool BooleanValue()) const;
V8_DEPRECATE_SOON("Use maybe version", double NumberValue()) const; V8_DEPRECATE_SOON("Use maybe version", double NumberValue()) const;
@ -2009,7 +2021,8 @@ class V8_EXPORT Value : public Data {
/** JS == */ /** JS == */
V8_DEPRECATE_SOON("Use maybe version", bool Equals(Handle<Value> that)) const; V8_DEPRECATE_SOON("Use maybe version", bool Equals(Handle<Value> that)) const;
Maybe<bool> Equals(Local<Context> context, Handle<Value> that) const; V8_WARN_UNUSED_RESULT Maybe<bool> Equals(Local<Context> context,
Handle<Value> that) const;
bool StrictEquals(Handle<Value> that) const; bool StrictEquals(Handle<Value> that) const;
bool SameValue(Handle<Value> that) const; bool SameValue(Handle<Value> that) const;
@ -2286,8 +2299,8 @@ class V8_EXPORT String : public Name {
/** Allocates a new string from UTF-8 data. Only returns an empty value when /** Allocates a new string from UTF-8 data. Only returns an empty value when
* length > kMaxLength. **/ * length > kMaxLength. **/
static MaybeLocal<String> NewFromUtf8(Isolate* isolate, const char* data, static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromUtf8(
v8::NewStringType type, Isolate* isolate, const char* data, v8::NewStringType type,
int length = -1); int length = -1);
/** Allocates a new string from Latin-1 data.*/ /** Allocates a new string from Latin-1 data.*/
@ -2299,9 +2312,8 @@ class V8_EXPORT String : public Name {
/** Allocates a new string from Latin-1 data. Only returns an empty value /** Allocates a new string from Latin-1 data. Only returns an empty value
* when length > kMaxLength. **/ * when length > kMaxLength. **/
static MaybeLocal<String> NewFromOneByte(Isolate* isolate, static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromOneByte(
const uint8_t* data, Isolate* isolate, const uint8_t* data, v8::NewStringType type,
v8::NewStringType type,
int length = -1); int length = -1);
/** Allocates a new string from UTF-16 data.*/ /** Allocates a new string from UTF-16 data.*/
@ -2313,9 +2325,8 @@ class V8_EXPORT String : public Name {
/** Allocates a new string from UTF-16 data. Only returns an empty value when /** Allocates a new string from UTF-16 data. Only returns an empty value when
* length > kMaxLength. **/ * length > kMaxLength. **/
static MaybeLocal<String> NewFromTwoByte(Isolate* isolate, static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromTwoByte(
const uint16_t* data, Isolate* isolate, const uint16_t* data, v8::NewStringType type,
v8::NewStringType type,
int length = -1); int length = -1);
/** /**
@ -2336,7 +2347,7 @@ class V8_EXPORT String : public Name {
"Use maybe version", "Use maybe version",
Local<String> NewExternal(Isolate* isolate, Local<String> NewExternal(Isolate* isolate,
ExternalStringResource* resource)); ExternalStringResource* resource));
static MaybeLocal<String> NewExternalTwoByte( static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalTwoByte(
Isolate* isolate, ExternalStringResource* resource); Isolate* isolate, ExternalStringResource* resource);
/** /**
@ -2362,7 +2373,7 @@ class V8_EXPORT String : public Name {
"Use maybe version", "Use maybe version",
Local<String> NewExternal(Isolate* isolate, Local<String> NewExternal(Isolate* isolate,
ExternalOneByteStringResource* resource)); ExternalOneByteStringResource* resource));
static MaybeLocal<String> NewExternalOneByte( static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalOneByte(
Isolate* isolate, ExternalOneByteStringResource* resource); Isolate* isolate, ExternalOneByteStringResource* resource);
/** /**
@ -2634,11 +2645,13 @@ class V8_EXPORT Object : public Value {
public: public:
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
bool Set(Handle<Value> key, Handle<Value> value)); bool Set(Handle<Value> key, Handle<Value> value));
Maybe<bool> Set(Local<Context> context, Local<Value> key, Local<Value> value); V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
Local<Value> key, Local<Value> value);
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
bool Set(uint32_t index, Handle<Value> value)); bool Set(uint32_t index, Handle<Value> value));
Maybe<bool> Set(Local<Context> context, uint32_t index, Local<Value> value); V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
Local<Value> value);
// Sets an own property on this object bypassing interceptors and // Sets an own property on this object bypassing interceptors and
// overriding accessors or read-only properties. // overriding accessors or read-only properties.
@ -2651,14 +2664,17 @@ class V8_EXPORT Object : public Value {
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
bool ForceSet(Handle<Value> key, Handle<Value> value, bool ForceSet(Handle<Value> key, Handle<Value> value,
PropertyAttribute attribs = None)); PropertyAttribute attribs = None));
// TODO(dcarney): mark V8_WARN_UNUSED_RESULT
Maybe<bool> ForceSet(Local<Context> context, Local<Value> key, Maybe<bool> ForceSet(Local<Context> context, Local<Value> key,
Local<Value> value, PropertyAttribute attribs = None); Local<Value> value, PropertyAttribute attribs = None);
V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Handle<Value> key)); V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Handle<Value> key));
MaybeLocal<Value> Get(Local<Context> context, Local<Value> key); V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
Local<Value> key);
V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(uint32_t index)); V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(uint32_t index));
MaybeLocal<Value> Get(Local<Context> context, uint32_t index); V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
uint32_t index);
/** /**
* Gets the property attributes of a property which can be None or * Gets the property attributes of a property which can be None or
@ -2667,27 +2683,30 @@ class V8_EXPORT Object : public Value {
*/ */
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
PropertyAttribute GetPropertyAttributes(Handle<Value> key)); PropertyAttribute GetPropertyAttributes(Handle<Value> key));
Maybe<PropertyAttribute> GetPropertyAttributes(Local<Context> context, V8_WARN_UNUSED_RESULT Maybe<PropertyAttribute> GetPropertyAttributes(
Local<Value> key); Local<Context> context, Local<Value> key);
/** /**
* Returns Object.getOwnPropertyDescriptor as per ES5 section 15.2.3.3. * Returns Object.getOwnPropertyDescriptor as per ES5 section 15.2.3.3.
*/ */
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
Local<Value> GetOwnPropertyDescriptor(Local<String> key)); Local<Value> GetOwnPropertyDescriptor(Local<String> key));
MaybeLocal<Value> GetOwnPropertyDescriptor(Local<Context> context, V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetOwnPropertyDescriptor(
Local<String> key); Local<Context> context, Local<String> key);
V8_DEPRECATE_SOON("Use maybe version", bool Has(Handle<Value> key)); V8_DEPRECATE_SOON("Use maybe version", bool Has(Handle<Value> key));
Maybe<bool> Has(Local<Context> context, Local<Value> key); V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context,
Local<Value> key);
V8_DEPRECATE_SOON("Use maybe version", bool Delete(Handle<Value> key)); V8_DEPRECATE_SOON("Use maybe version", bool Delete(Handle<Value> key));
// TODO(dcarney): mark V8_WARN_UNUSED_RESULT
Maybe<bool> Delete(Local<Context> context, Local<Value> key); Maybe<bool> Delete(Local<Context> context, Local<Value> key);
V8_DEPRECATE_SOON("Use maybe version", bool Has(uint32_t index)); V8_DEPRECATE_SOON("Use maybe version", bool Has(uint32_t index));
Maybe<bool> Has(Local<Context> context, uint32_t index); V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, uint32_t index);
V8_DEPRECATE_SOON("Use maybe version", bool Delete(uint32_t index)); V8_DEPRECATE_SOON("Use maybe version", bool Delete(uint32_t index));
// TODO(dcarney): mark V8_WARN_UNUSED_RESULT
Maybe<bool> Delete(Local<Context> context, uint32_t index); Maybe<bool> Delete(Local<Context> context, uint32_t index);
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
@ -2704,6 +2723,7 @@ class V8_EXPORT Object : public Value {
Handle<Value> data = Handle<Value>(), Handle<Value> data = Handle<Value>(),
AccessControl settings = DEFAULT, AccessControl settings = DEFAULT,
PropertyAttribute attribute = None)); PropertyAttribute attribute = None));
// TODO(dcarney): mark V8_WARN_UNUSED_RESULT
Maybe<bool> SetAccessor(Local<Context> context, Local<Name> name, Maybe<bool> SetAccessor(Local<Context> context, Local<Name> name,
AccessorNameGetterCallback getter, AccessorNameGetterCallback getter,
AccessorNameSetterCallback setter = 0, AccessorNameSetterCallback setter = 0,
@ -2736,7 +2756,8 @@ class V8_EXPORT Object : public Value {
* be enumerated by a for-in statement over this object. * be enumerated by a for-in statement over this object.
*/ */
V8_DEPRECATE_SOON("Use maybe version", Local<Array> GetPropertyNames()); V8_DEPRECATE_SOON("Use maybe version", Local<Array> GetPropertyNames());
MaybeLocal<Array> GetPropertyNames(Local<Context> context); V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetPropertyNames(
Local<Context> context);
/** /**
* This function has the same functionality as GetPropertyNames but * This function has the same functionality as GetPropertyNames but
@ -2744,7 +2765,8 @@ class V8_EXPORT Object : public Value {
* prototype objects. * prototype objects.
*/ */
V8_DEPRECATE_SOON("Use maybe version", Local<Array> GetOwnPropertyNames()); V8_DEPRECATE_SOON("Use maybe version", Local<Array> GetOwnPropertyNames());
MaybeLocal<Array> GetOwnPropertyNames(Local<Context> context); V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetOwnPropertyNames(
Local<Context> context);
/** /**
* Get the prototype object. This does not skip objects marked to * Get the prototype object. This does not skip objects marked to
@ -2760,7 +2782,8 @@ class V8_EXPORT Object : public Value {
*/ */
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
bool SetPrototype(Handle<Value> prototype)); bool SetPrototype(Handle<Value> prototype));
Maybe<bool> SetPrototype(Local<Context> context, Local<Value> prototype); V8_WARN_UNUSED_RESULT Maybe<bool> SetPrototype(Local<Context> context,
Local<Value> prototype);
/** /**
* Finds an instance of the given function template in the prototype * Finds an instance of the given function template in the prototype
@ -2774,7 +2797,8 @@ class V8_EXPORT Object : public Value {
* user-defined toString function. This one does not. * user-defined toString function. This one does not.
*/ */
V8_DEPRECATE_SOON("Use maybe version", Local<String> ObjectProtoToString()); V8_DEPRECATE_SOON("Use maybe version", Local<String> ObjectProtoToString());
MaybeLocal<String> ObjectProtoToString(Local<Context> context); V8_WARN_UNUSED_RESULT MaybeLocal<String> ObjectProtoToString(
Local<Context> context);
/** /**
* Returns the name of the function invoked as a constructor for this object. * Returns the name of the function invoked as a constructor for this object.
@ -2819,17 +2843,20 @@ class V8_EXPORT Object : public Value {
// Testers for local properties. // Testers for local properties.
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
bool HasOwnProperty(Handle<String> key)); bool HasOwnProperty(Handle<String> key));
Maybe<bool> HasOwnProperty(Local<Context> context, Local<Name> key); V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context,
Local<Name> key);
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
bool HasRealNamedProperty(Handle<String> key)); bool HasRealNamedProperty(Handle<String> key));
Maybe<bool> HasRealNamedProperty(Local<Context> context, Local<Name> key); V8_WARN_UNUSED_RESULT Maybe<bool> HasRealNamedProperty(Local<Context> context,
Local<Name> key);
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
bool HasRealIndexedProperty(uint32_t index)); bool HasRealIndexedProperty(uint32_t index));
Maybe<bool> HasRealIndexedProperty(Local<Context> context, uint32_t index); V8_WARN_UNUSED_RESULT Maybe<bool> HasRealIndexedProperty(
Local<Context> context, uint32_t index);
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
bool HasRealNamedCallbackProperty(Handle<String> key)); bool HasRealNamedCallbackProperty(Handle<String> key));
Maybe<bool> HasRealNamedCallbackProperty(Local<Context> context, V8_WARN_UNUSED_RESULT Maybe<bool> HasRealNamedCallbackProperty(
Local<Name> key); Local<Context> context, Local<Name> key);
/** /**
* If result.IsEmpty() no real property was located in the prototype chain. * If result.IsEmpty() no real property was located in the prototype chain.
@ -2838,8 +2865,8 @@ class V8_EXPORT Object : public Value {
V8_DEPRECATE_SOON( V8_DEPRECATE_SOON(
"Use maybe version", "Use maybe version",
Local<Value> GetRealNamedPropertyInPrototypeChain(Handle<String> key)); Local<Value> GetRealNamedPropertyInPrototypeChain(Handle<String> key));
MaybeLocal<Value> GetRealNamedPropertyInPrototypeChain(Local<Context> context, V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetRealNamedPropertyInPrototypeChain(
Local<Name> key); Local<Context> context, Local<Name> key);
/** /**
* Gets the property attributes of a real property in the prototype chain, * Gets the property attributes of a real property in the prototype chain,
@ -2850,8 +2877,9 @@ class V8_EXPORT Object : public Value {
"Use maybe version", "Use maybe version",
Maybe<PropertyAttribute> GetRealNamedPropertyAttributesInPrototypeChain( Maybe<PropertyAttribute> GetRealNamedPropertyAttributesInPrototypeChain(
Handle<String> key)); Handle<String> key));
Maybe<PropertyAttribute> GetRealNamedPropertyAttributesInPrototypeChain( V8_WARN_UNUSED_RESULT Maybe<PropertyAttribute>
Local<Context> context, Local<Name> key); GetRealNamedPropertyAttributesInPrototypeChain(Local<Context> context,
Local<Name> key);
/** /**
* If result.IsEmpty() no real property was located on the object or * If result.IsEmpty() no real property was located on the object or
@ -2860,8 +2888,8 @@ class V8_EXPORT Object : public Value {
*/ */
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
Local<Value> GetRealNamedProperty(Handle<String> key)); Local<Value> GetRealNamedProperty(Handle<String> key));
MaybeLocal<Value> GetRealNamedProperty(Local<Context> context, V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetRealNamedProperty(
Local<Name> key); Local<Context> context, Local<Name> key);
/** /**
* Gets the property attributes of a real property which can be * Gets the property attributes of a real property which can be
@ -2871,7 +2899,7 @@ class V8_EXPORT Object : public Value {
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
Maybe<PropertyAttribute> GetRealNamedPropertyAttributes( Maybe<PropertyAttribute> GetRealNamedPropertyAttributes(
Handle<String> key)); Handle<String> key));
Maybe<PropertyAttribute> GetRealNamedPropertyAttributes( V8_WARN_UNUSED_RESULT Maybe<PropertyAttribute> GetRealNamedPropertyAttributes(
Local<Context> context, Local<Name> key); Local<Context> context, Local<Name> key);
/** Tests for a named lookup interceptor.*/ /** Tests for a named lookup interceptor.*/
@ -2960,8 +2988,10 @@ class V8_EXPORT Object : public Value {
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
Local<Value> CallAsFunction(Handle<Value> recv, int argc, Local<Value> CallAsFunction(Handle<Value> recv, int argc,
Handle<Value> argv[])); Handle<Value> argv[]));
MaybeLocal<Value> CallAsFunction(Local<Context> context, Handle<Value> recv, V8_WARN_UNUSED_RESULT MaybeLocal<Value> CallAsFunction(Local<Context> context,
int argc, Handle<Value> argv[]); Handle<Value> recv,
int argc,
Handle<Value> argv[]);
/** /**
* Call an Object as a constructor if a callback is set by the * Call an Object as a constructor if a callback is set by the
@ -2971,8 +3001,8 @@ class V8_EXPORT Object : public Value {
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
Local<Value> CallAsConstructor(int argc, Local<Value> CallAsConstructor(int argc,
Handle<Value> argv[])); Handle<Value> argv[]));
MaybeLocal<Value> CallAsConstructor(Local<Context> context, int argc, V8_WARN_UNUSED_RESULT MaybeLocal<Value> CallAsConstructor(
Local<Value> argv[]); Local<Context> context, int argc, Local<Value> argv[]);
/** /**
* Return the isolate to which the Object belongs to. * Return the isolate to which the Object belongs to.
@ -3004,7 +3034,8 @@ class V8_EXPORT Array : public Object {
*/ */
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
Local<Object> CloneElementAt(uint32_t index)); Local<Object> CloneElementAt(uint32_t index));
MaybeLocal<Object> CloneElementAt(Local<Context> context, uint32_t index); V8_WARN_UNUSED_RESULT MaybeLocal<Object> CloneElementAt(
Local<Context> context, uint32_t index);
/** /**
* Creates a JavaScript array with the given length. If the length * Creates a JavaScript array with the given length. If the length
@ -3152,18 +3183,20 @@ class V8_EXPORT Function : public Object {
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
Local<Object> NewInstance(int argc, Local<Object> NewInstance(int argc,
Handle<Value> argv[])) const; Handle<Value> argv[])) const;
MaybeLocal<Object> NewInstance(Local<Context> context, int argc, V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
Handle<Value> argv[]) const; Local<Context> context, int argc, Handle<Value> argv[]) const;
V8_DEPRECATE_SOON("Use maybe version", Local<Object> NewInstance()) const; V8_DEPRECATE_SOON("Use maybe version", Local<Object> NewInstance()) const;
MaybeLocal<Object> NewInstance(Local<Context> context) const { V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
Local<Context> context) const {
return NewInstance(context, 0, nullptr); return NewInstance(context, 0, nullptr);
} }
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
Local<Value> Call(Handle<Value> recv, int argc, Local<Value> Call(Handle<Value> recv, int argc,
Handle<Value> argv[])); Handle<Value> argv[]));
MaybeLocal<Value> Call(Local<Context> context, Handle<Value> recv, int argc, V8_WARN_UNUSED_RESULT MaybeLocal<Value> Call(Local<Context> context,
Handle<Value> recv, int argc,
Handle<Value> argv[]); Handle<Value> argv[]);
void SetName(Handle<String> name); void SetName(Handle<String> name);
@ -3233,7 +3266,8 @@ class V8_EXPORT Promise : public Object {
*/ */
static V8_DEPRECATE_SOON("Use maybe version", static V8_DEPRECATE_SOON("Use maybe version",
Local<Resolver> New(Isolate* isolate)); Local<Resolver> New(Isolate* isolate));
static MaybeLocal<Resolver> New(Local<Context> context); static V8_WARN_UNUSED_RESULT MaybeLocal<Resolver> New(
Local<Context> context);
/** /**
* Extract the associated promise. * Extract the associated promise.
@ -3245,9 +3279,11 @@ class V8_EXPORT Promise : public Object {
* Ignored if the promise is no longer pending. * Ignored if the promise is no longer pending.
*/ */
V8_DEPRECATE_SOON("Use maybe version", void Resolve(Handle<Value> value)); V8_DEPRECATE_SOON("Use maybe version", void Resolve(Handle<Value> value));
// TODO(dcarney): mark V8_WARN_UNUSED_RESULT
Maybe<bool> Resolve(Local<Context> context, Handle<Value> value); Maybe<bool> Resolve(Local<Context> context, Handle<Value> value);
V8_DEPRECATE_SOON("Use maybe version", void Reject(Handle<Value> value)); V8_DEPRECATE_SOON("Use maybe version", void Reject(Handle<Value> value));
// TODO(dcarney): mark V8_WARN_UNUSED_RESULT
Maybe<bool> Reject(Local<Context> context, Handle<Value> value); Maybe<bool> Reject(Local<Context> context, Handle<Value> value);
V8_INLINE static Resolver* Cast(Value* obj); V8_INLINE static Resolver* Cast(Value* obj);
@ -3265,15 +3301,18 @@ class V8_EXPORT Promise : public Object {
*/ */
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
Local<Promise> Chain(Handle<Function> handler)); Local<Promise> Chain(Handle<Function> handler));
MaybeLocal<Promise> Chain(Local<Context> context, Handle<Function> handler); V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Chain(Local<Context> context,
Handle<Function> handler);
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
Local<Promise> Catch(Handle<Function> handler)); Local<Promise> Catch(Handle<Function> handler));
MaybeLocal<Promise> Catch(Local<Context> context, Handle<Function> handler); V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Catch(Local<Context> context,
Handle<Function> handler);
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
Local<Promise> Then(Handle<Function> handler)); Local<Promise> Then(Handle<Function> handler));
MaybeLocal<Promise> Then(Local<Context> context, Handle<Function> handler); V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Then(Local<Context> context,
Handle<Function> handler);
/** /**
* Returns true if the promise has at least one derived promise, and * Returns true if the promise has at least one derived promise, and
@ -3641,7 +3680,8 @@ class V8_EXPORT Date : public Object {
public: public:
static V8_DEPRECATE_SOON("Use maybe version.", static V8_DEPRECATE_SOON("Use maybe version.",
Local<Value> New(Isolate* isolate, double time)); Local<Value> New(Isolate* isolate, double time));
static MaybeLocal<Value> New(Local<Context> context, double time); static V8_WARN_UNUSED_RESULT MaybeLocal<Value> New(Local<Context> context,
double time);
/** /**
* A specialization of Value::NumberValue that is more efficient * A specialization of Value::NumberValue that is more efficient
@ -3765,7 +3805,8 @@ class V8_EXPORT RegExp : public Object {
static V8_DEPRECATE_SOON("Use maybe version", static V8_DEPRECATE_SOON("Use maybe version",
Local<RegExp> New(Handle<String> pattern, Local<RegExp> New(Handle<String> pattern,
Flags flags)); Flags flags));
static MaybeLocal<RegExp> New(Local<Context> context, Handle<String> pattern, static V8_WARN_UNUSED_RESULT MaybeLocal<RegExp> New(Local<Context> context,
Handle<String> pattern,
Flags flags); Flags flags);
/** /**
@ -4151,7 +4192,8 @@ class V8_EXPORT FunctionTemplate : public Template {
/** Returns the unique function instance in the current execution context.*/ /** Returns the unique function instance in the current execution context.*/
V8_DEPRECATE_SOON("Use maybe version", Local<Function> GetFunction()); V8_DEPRECATE_SOON("Use maybe version", Local<Function> GetFunction());
MaybeLocal<Function> GetFunction(Local<Context> context); V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction(
Local<Context> context);
/** /**
* Set the call-handler callback for a FunctionTemplate. This * Set the call-handler callback for a FunctionTemplate. This
@ -4312,7 +4354,7 @@ class V8_EXPORT ObjectTemplate : public Template {
/** Creates a new instance of this template.*/ /** Creates a new instance of this template.*/
V8_DEPRECATE_SOON("Use maybe version", Local<Object> NewInstance()); V8_DEPRECATE_SOON("Use maybe version", Local<Object> NewInstance());
MaybeLocal<Object> NewInstance(Local<Context> context); V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(Local<Context> context);
/** /**
* Sets an accessor on the object template. * Sets an accessor on the object template.
@ -6154,7 +6196,8 @@ class V8_EXPORT TryCatch {
* property is present an empty handle is returned. * property is present an empty handle is returned.
*/ */
V8_DEPRECATE_SOON("Use maybe version.", Local<Value> StackTrace()) const; V8_DEPRECATE_SOON("Use maybe version.", Local<Value> StackTrace()) const;
MaybeLocal<Value> StackTrace(Local<Context> context) const; V8_WARN_UNUSED_RESULT MaybeLocal<Value> StackTrace(
Local<Context> context) const;
/** /**
* Returns the message associated with this exception. If there is * Returns the message associated with this exception. If there is

View File

@ -1675,8 +1675,8 @@ MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal(
} }
i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string)); i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string));
i::SharedFunctionInfo* raw_result = NULL; i::Handle<i::SharedFunctionInfo> result;
{ i::HandleScope scope(isolate); {
i::HistogramTimerScope total(isolate->counters()->compile_script(), true); i::HistogramTimerScope total(isolate->counters()->compile_script(), true);
i::Handle<i::Object> name_obj; i::Handle<i::Object> name_obj;
i::Handle<i::Object> source_map_url; i::Handle<i::Object> source_map_url;
@ -1705,7 +1705,7 @@ MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal(
if (!source->source_map_url.IsEmpty()) { if (!source->source_map_url.IsEmpty()) {
source_map_url = Utils::OpenHandle(*(source->source_map_url)); source_map_url = Utils::OpenHandle(*(source->source_map_url));
} }
i::Handle<i::SharedFunctionInfo> result = i::Compiler::CompileScript( result = i::Compiler::CompileScript(
str, name_obj, line_offset, column_offset, is_embedder_debug_script, str, name_obj, line_offset, column_offset, is_embedder_debug_script,
is_shared_cross_origin, source_map_url, isolate->native_context(), NULL, is_shared_cross_origin, source_map_url, isolate->native_context(), NULL,
&script_data, options, i::NOT_NATIVES_CODE, is_module); &script_data, options, i::NOT_NATIVES_CODE, is_module);
@ -1718,7 +1718,6 @@ MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal(
script_data = NULL; script_data = NULL;
} }
RETURN_ON_FAILED_EXECUTION(UnboundScript); RETURN_ON_FAILED_EXECUTION(UnboundScript);
raw_result = *result;
if ((options == kProduceParserCache || options == kProduceCodeCache) && if ((options == kProduceParserCache || options == kProduceCodeCache) &&
script_data != NULL) { script_data != NULL) {
@ -1732,7 +1731,6 @@ MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal(
} }
delete script_data; delete script_data;
} }
i::Handle<i::SharedFunctionInfo> result(raw_result, isolate);
RETURN_ESCAPED(ToApiHandle<UnboundScript>(result)); RETURN_ESCAPED(ToApiHandle<UnboundScript>(result));
} }
@ -1931,9 +1929,6 @@ MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context,
const ScriptOrigin& origin) { const ScriptOrigin& origin) {
PREPARE_FOR_EXECUTION(context, "v8::ScriptCompiler::Compile()", Script); PREPARE_FOR_EXECUTION(context, "v8::ScriptCompiler::Compile()", Script);
i::StreamedSource* source = v8_source->impl(); i::StreamedSource* source = v8_source->impl();
i::SharedFunctionInfo* raw_result = nullptr;
{
i::HandleScope scope(isolate);
i::Handle<i::String> str = Utils::OpenHandle(*(full_source_string)); i::Handle<i::String> str = Utils::OpenHandle(*(full_source_string));
i::Handle<i::Script> script = isolate->factory()->NewScript(str); i::Handle<i::Script> script = isolate->factory()->NewScript(str);
if (!origin.ResourceName().IsEmpty()) { if (!origin.ResourceName().IsEmpty()) {
@ -1980,10 +1975,7 @@ MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context,
RETURN_ON_FAILED_EXECUTION(Script); RETURN_ON_FAILED_EXECUTION(Script);
source->info->clear_script(); // because script goes out of scope. source->info->clear_script(); // because script goes out of scope.
raw_result = *result; // TODO(titzer): use CloseAndEscape?
}
i::Handle<i::SharedFunctionInfo> result(raw_result, isolate);
Local<UnboundScript> generic = ToApiHandle<UnboundScript>(result); Local<UnboundScript> generic = ToApiHandle<UnboundScript>(result);
if (generic.IsEmpty()) return Local<Script>(); if (generic.IsEmpty()) return Local<Script>();
Local<Script> bound = generic->BindToCurrentContext(); Local<Script> bound = generic->BindToCurrentContext();
@ -6255,7 +6247,7 @@ Maybe<bool> Promise::Resolver::Resolve(Local<Context> context,
void Promise::Resolver::Resolve(Handle<Value> value) { void Promise::Resolver::Resolve(Handle<Value> value) {
auto context = ContextFromHeapObject(Utils::OpenHandle(this)); auto context = ContextFromHeapObject(Utils::OpenHandle(this));
Resolve(context, value); USE(Resolve(context, value));
} }
@ -6277,7 +6269,7 @@ Maybe<bool> Promise::Resolver::Reject(Local<Context> context,
void Promise::Resolver::Reject(Handle<Value> value) { void Promise::Resolver::Reject(Handle<Value> value) {
auto context = ContextFromHeapObject(Utils::OpenHandle(this)); auto context = ContextFromHeapObject(Utils::OpenHandle(this));
Reject(context, value); USE(Reject(context, value));
} }