Commit 800f9f7d authored by jochen@chromium.org's avatar jochen@chromium.org

Don't use Persistent in runtime

R=dcarney@chromium.org, mstarzinger@chromium.org
BUG=none

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16234 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 76a820a9
...@@ -800,7 +800,7 @@ icu::SimpleDateFormat* DateFormat::UnpackDateFormat( ...@@ -800,7 +800,7 @@ icu::SimpleDateFormat* DateFormat::UnpackDateFormat(
void DateFormat::DeleteDateFormat(v8::Isolate* isolate, void DateFormat::DeleteDateFormat(v8::Isolate* isolate,
Persistent<v8::Object>* object, Persistent<v8::Value>* object,
void* param) { void* param) {
// First delete the hidden C++ object. // First delete the hidden C++ object.
delete reinterpret_cast<icu::SimpleDateFormat*>(Handle<JSObject>::cast( delete reinterpret_cast<icu::SimpleDateFormat*>(Handle<JSObject>::cast(
...@@ -864,7 +864,7 @@ icu::DecimalFormat* NumberFormat::UnpackNumberFormat( ...@@ -864,7 +864,7 @@ icu::DecimalFormat* NumberFormat::UnpackNumberFormat(
void NumberFormat::DeleteNumberFormat(v8::Isolate* isolate, void NumberFormat::DeleteNumberFormat(v8::Isolate* isolate,
Persistent<v8::Object>* object, Persistent<v8::Value>* object,
void* param) { void* param) {
// First delete the hidden C++ object. // First delete the hidden C++ object.
delete reinterpret_cast<icu::DecimalFormat*>(Handle<JSObject>::cast( delete reinterpret_cast<icu::DecimalFormat*>(Handle<JSObject>::cast(
...@@ -925,7 +925,7 @@ icu::Collator* Collator::UnpackCollator(Isolate* isolate, ...@@ -925,7 +925,7 @@ icu::Collator* Collator::UnpackCollator(Isolate* isolate,
void Collator::DeleteCollator(v8::Isolate* isolate, void Collator::DeleteCollator(v8::Isolate* isolate,
Persistent<v8::Object>* object, Persistent<v8::Value>* object,
void* param) { void* param) {
// First delete the hidden C++ object. // First delete the hidden C++ object.
delete reinterpret_cast<icu::Collator*>(Handle<JSObject>::cast( delete reinterpret_cast<icu::Collator*>(Handle<JSObject>::cast(
......
...@@ -71,7 +71,7 @@ class DateFormat { ...@@ -71,7 +71,7 @@ class DateFormat {
// Release memory we allocated for the DateFormat once the JS object that // Release memory we allocated for the DateFormat once the JS object that
// holds the pointer gets garbage collected. // holds the pointer gets garbage collected.
static void DeleteDateFormat(v8::Isolate* isolate, static void DeleteDateFormat(v8::Isolate* isolate,
Persistent<v8::Object>* object, Persistent<v8::Value>* object,
void* param); void* param);
private: private:
DateFormat(); DateFormat();
...@@ -95,7 +95,7 @@ class NumberFormat { ...@@ -95,7 +95,7 @@ class NumberFormat {
// Release memory we allocated for the NumberFormat once the JS object that // Release memory we allocated for the NumberFormat once the JS object that
// holds the pointer gets garbage collected. // holds the pointer gets garbage collected.
static void DeleteNumberFormat(v8::Isolate* isolate, static void DeleteNumberFormat(v8::Isolate* isolate,
Persistent<v8::Object>* object, Persistent<v8::Value>* object,
void* param); void* param);
private: private:
NumberFormat(); NumberFormat();
...@@ -118,7 +118,7 @@ class Collator { ...@@ -118,7 +118,7 @@ class Collator {
// Release memory we allocated for the Collator once the JS object that holds // Release memory we allocated for the Collator once the JS object that holds
// the pointer gets garbage collected. // the pointer gets garbage collected.
static void DeleteCollator(v8::Isolate* isolate, static void DeleteCollator(v8::Isolate* isolate,
Persistent<v8::Object>* object, Persistent<v8::Value>* object,
void* param); void* param);
private: private:
Collator(); Collator();
......
...@@ -13631,11 +13631,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateDateTimeFormat) { ...@@ -13631,11 +13631,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateDateTimeFormat) {
isolate->factory()->NewStringFromAscii(CStrVector("valid")), isolate->factory()->NewStringFromAscii(CStrVector("valid")),
NONE)); NONE));
Persistent<v8::Object> wrapper(reinterpret_cast<v8::Isolate*>(isolate),
v8::Utils::ToLocal(local_object));
// Make object handle weak so we can delete the data format once GC kicks in. // Make object handle weak so we can delete the data format once GC kicks in.
wrapper.MakeWeak<void>(NULL, &DateFormat::DeleteDateFormat); Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
wrapper.ClearAndLeak(); GlobalHandles::MakeWeak(reinterpret_cast<Object**>(wrapper.location()),
NULL,
DateFormat::DeleteDateFormat);
return *local_object; return *local_object;
} }
...@@ -13734,12 +13734,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateNumberFormat) { ...@@ -13734,12 +13734,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateNumberFormat) {
isolate->factory()->NewStringFromAscii(CStrVector("valid")), isolate->factory()->NewStringFromAscii(CStrVector("valid")),
NONE)); NONE));
Persistent<v8::Object> wrapper(reinterpret_cast<v8::Isolate*>(isolate), Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
v8::Utils::ToLocal(local_object)); GlobalHandles::MakeWeak(reinterpret_cast<Object**>(wrapper.location()),
// Make object handle weak so we can delete the number format once GC kicks NULL,
// in. NumberFormat::DeleteNumberFormat);
wrapper.MakeWeak<void>(NULL, &NumberFormat::DeleteNumberFormat);
wrapper.ClearAndLeak();
return *local_object; return *local_object;
} }
...@@ -13847,11 +13845,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateCollator) { ...@@ -13847,11 +13845,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateCollator) {
isolate->factory()->NewStringFromAscii(CStrVector("valid")), isolate->factory()->NewStringFromAscii(CStrVector("valid")),
NONE)); NONE));
Persistent<v8::Object> wrapper(reinterpret_cast<v8::Isolate*>(isolate), Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
v8::Utils::ToLocal(local_object)); GlobalHandles::MakeWeak(reinterpret_cast<Object**>(wrapper.location()),
// Make object handle weak so we can delete the collator once GC kicks in. NULL,
wrapper.MakeWeak<void>(NULL, &Collator::DeleteCollator); Collator::DeleteCollator);
wrapper.ClearAndLeak();
return *local_object; return *local_object;
} }
......
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