From: dslomov@chromium.org Date: Wed, 18 May 2011 23:26:38 +0000 (+0000) Subject: Put 7942 "Per-isolate embedder-specific data" back X-Git-Tag: upstream/4.7.83~19370 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c5c57d722a03f2d080e635a88966720f15e1aaa6;p=platform%2Fupstream%2Fv8.git Put 7942 "Per-isolate embedder-specific data" back TBR= git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7947 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/include/v8.h b/include/v8.h index 411c2f1..fce50fc 100644 --- a/include/v8.h +++ b/include/v8.h @@ -2670,6 +2670,17 @@ class V8EXPORT Isolate { */ void Dispose(); + /** + * Associate embedder-specific data with the isolate + */ + void SetData(void* data); + + /** + * Retrive embedder-specific data from the isolate. + * Returns NULL if SetData has never been called. + */ + void* GetData(); + private: Isolate(); diff --git a/src/api.cc b/src/api.cc index 30e0881..6369a9f 100644 --- a/src/api.cc +++ b/src/api.cc @@ -4870,6 +4870,17 @@ void Isolate::Exit() { } +void Isolate::SetData(void* data) { + i::Isolate* isolate = reinterpret_cast(this); + isolate->SetData(data); +} + +void* Isolate::GetData() { + i::Isolate* isolate = reinterpret_cast(this); + return isolate->GetData(); +} + + String::Utf8Value::Utf8Value(v8::Handle obj) : str_(NULL), length_(0) { i::Isolate* isolate = i::Isolate::Current(); diff --git a/src/isolate.cc b/src/isolate.cc index 22a659a..a7bf7d9 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -1397,7 +1397,8 @@ Isolate::Isolate() string_tracker_(NULL), regexp_stack_(NULL), frame_element_constant_list_(0), - result_constant_list_(0) { + result_constant_list_(0), + embedder_data_(NULL) { TRACE_ISOLATE(constructor); memset(isolate_addresses_, 0, diff --git a/src/isolate.h b/src/isolate.h index 088c247..fbe0b43 100644 --- a/src/isolate.h +++ b/src/isolate.h @@ -994,6 +994,9 @@ class Isolate { void ResetEagerOptimizingData(); + void SetData(void* data) { embedder_data_ = data; } + void* GetData() { return embedder_data_; } + private: Isolate(); @@ -1156,6 +1159,7 @@ class Isolate { unibrow::Mapping interp_canonicalize_mapping_; ZoneObjectList frame_element_constant_list_; ZoneObjectList result_constant_list_; + void* embedder_data_; #if defined(V8_TARGET_ARCH_ARM) && !defined(__arm__) || \ defined(V8_TARGET_ARCH_MIPS) && !defined(__mips__)