Reviewers: rossberg,
Message:
The path taken to get to this bug is twisted -- api.cc's
ObjectTemplate::NewInstance calls execution.cc calls the Instantiate
function
from apinatives.js with one argument, which visits the strange property
array to
initialize the template, which eventually recurses and calls Instantiate()
with
two arguments, the second one being a symbol name, which then flows into
InstantiateFunction, which eventually fails to FunctionSetName with a symbol
argument.
Description:
Fix symbol-named function template properties in the API
Thanks to Yutaka Hirano <[email protected]> for finding the bug and
providing the test case.
[email protected]
BUG=
Please review this at https://codereview.chromium.org/496663002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+15, -1 lines):
M src/apinatives.js
M test/cctest/test-api.cc
Index: src/apinatives.js
diff --git a/src/apinatives.js b/src/apinatives.js
index
dda1d24bab2b2014ffd6aabf1eb20914f3924424..3e38d100358041fe50536bf4523592ad311fe430
100644
--- a/src/apinatives.js
+++ b/src/apinatives.js
@@ -72,7 +72,7 @@ function InstantiateFunction(data, name) {
}
}
var fun = %CreateApiFunction(data, prototype);
- if (name) %FunctionSetName(fun, name);
+ if (IS_STRING(name)) %FunctionSetName(fun, name);
var doNotCache = flags & (1 << kDoNotCacheBit);
if (!doNotCache) cache[serialNumber] = fun;
ConfigureTemplateInstance(fun, data);
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
a89c996f29379f02893e07f668f3d094b8fb861a..7eead79725e89c63ca95ee7697d5f9ec37098dfa
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -2886,6 +2886,20 @@ THREADED_TEST(SymbolProperties) {
}
+THREADED_TEST(SymbolTemplateProperties) {
+ LocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+ v8::Local<v8::FunctionTemplate> foo = v8::FunctionTemplate::New(isolate);
+ v8::Local<v8::Name> name = v8::Symbol::New(isolate);
+ CHECK(!name.IsEmpty());
+ foo->PrototypeTemplate()->Set(name, v8::FunctionTemplate::New(isolate));
+ v8::Local<v8::Object> new_instance =
foo->InstanceTemplate()->NewInstance();
+ CHECK(!new_instance.IsEmpty());
+ CHECK(new_instance->Has(name));
+}
+
+
THREADED_TEST(PrivateProperties) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.