Commit 91efd1e7 authored by dcarney@chromium.org's avatar dcarney@chromium.org

callback handler map not correctly populated by direct use of SetCallHandler

R=svenpanne@chromium.org
BUG=

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14789 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 22a336c1
...@@ -982,7 +982,7 @@ void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) { ...@@ -982,7 +982,7 @@ void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) {
template<typename Callback> template<typename Callback>
static Local<FunctionTemplate> FunctionTemplateNew( static Local<FunctionTemplate> FunctionTemplateNew(
Callback callback_in, Callback callback,
v8::Handle<Value> data, v8::Handle<Value> data,
v8::Handle<Signature> signature, v8::Handle<Signature> signature,
int length) { int length) {
...@@ -998,10 +998,8 @@ static Local<FunctionTemplate> FunctionTemplateNew( ...@@ -998,10 +998,8 @@ static Local<FunctionTemplate> FunctionTemplateNew(
int next_serial_number = isolate->next_serial_number(); int next_serial_number = isolate->next_serial_number();
isolate->set_next_serial_number(next_serial_number + 1); isolate->set_next_serial_number(next_serial_number + 1);
obj->set_serial_number(i::Smi::FromInt(next_serial_number)); obj->set_serial_number(i::Smi::FromInt(next_serial_number));
if (callback_in != 0) { if (callback != 0) {
if (data.IsEmpty()) data = v8::Undefined(); if (data.IsEmpty()) data = v8::Undefined();
InvocationCallback callback =
i::CallbackTable::Register(isolate, callback_in);
Utils::ToLocal(obj)->SetCallHandler(callback, data); Utils::ToLocal(obj)->SetCallHandler(callback, data);
} }
obj->set_length(length); obj->set_length(length);
...@@ -1225,7 +1223,7 @@ int TypeSwitch::match(v8::Handle<Value> value) { ...@@ -1225,7 +1223,7 @@ int TypeSwitch::match(v8::Handle<Value> value) {
template<typename Callback> template<typename Callback>
static void FunctionTemplateSetCallHandler(FunctionTemplate* function_template, static void FunctionTemplateSetCallHandler(FunctionTemplate* function_template,
Callback callback, Callback callback_in,
v8::Handle<Value> data) { v8::Handle<Value> data) {
i::Isolate* isolate = Utils::OpenHandle(function_template)->GetIsolate(); i::Isolate* isolate = Utils::OpenHandle(function_template)->GetIsolate();
if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetCallHandler()")) return; if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetCallHandler()")) return;
...@@ -1235,6 +1233,8 @@ static void FunctionTemplateSetCallHandler(FunctionTemplate* function_template, ...@@ -1235,6 +1233,8 @@ static void FunctionTemplateSetCallHandler(FunctionTemplate* function_template,
isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE);
i::Handle<i::CallHandlerInfo> obj = i::Handle<i::CallHandlerInfo> obj =
i::Handle<i::CallHandlerInfo>::cast(struct_obj); i::Handle<i::CallHandlerInfo>::cast(struct_obj);
InvocationCallback callback =
i::CallbackTable::Register(isolate, callback_in);
SET_FIELD_WRAPPED(obj, set_callback, callback); SET_FIELD_WRAPPED(obj, set_callback, callback);
if (data.IsEmpty()) data = v8::Undefined(); if (data.IsEmpty()) data = v8::Undefined();
obj->set_data(*Utils::OpenHandle(*data)); obj->set_data(*Utils::OpenHandle(*data));
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "v8.h" #include "v8.h"
#include "api.h" #include "api.h"
#include "arguments.h"
#include "isolate.h" #include "isolate.h"
#include "compilation-cache.h" #include "compilation-cache.h"
#include "execution.h" #include "execution.h"
...@@ -908,6 +909,12 @@ static void TestFunctionTemplateInitializer(Handler handler) { ...@@ -908,6 +909,12 @@ static void TestFunctionTemplateInitializer(Handler handler) {
CHECK_EQ(102, script->Run()->Int32Value()); CHECK_EQ(102, script->Run()->Int32Value());
} }
} }
// Blow away handler database
i::Isolate* isolate = i::Isolate::Current();
if (isolate->callback_table() != NULL) {
delete isolate->callback_table();
isolate->set_callback_table(NULL);
}
// Use SetCallHandler to initialize a function template, should work like the // Use SetCallHandler to initialize a function template, should work like the
// previous one. // previous one.
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment