Remove all stuff marked as V8_DEPRECATED.

R=jochen@chromium.org, mstarzinger@chromium.org, yurys@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18333 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
svenpanne@chromium.org 2013-12-18 08:09:37 +00:00
parent dc25e0c4a8
commit 402139f686
17 changed files with 226 additions and 828 deletions

View File

@ -475,21 +475,6 @@ class V8_EXPORT HeapProfiler {
*/
void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info);
/**
* Starts recording JS allocations immediately as they arrive and tracking of
* heap objects population statistics.
*/
V8_DEPRECATED("Use StartTrackingHeapObjects instead",
void StartRecordingHeapAllocations());
/**
* Stops recording JS allocations and tracking of heap objects population
* statistics, cleans all collected heap objects population statistics data.
*/
V8_DEPRECATED("Use StopTrackingHeapObjects instead",
void StopRecordingHeapAllocations());
private:
HeapProfiler();
~HeapProfiler();

View File

@ -455,18 +455,6 @@ class WeakCallbackData {
};
// TODO(dcarney): Remove this class.
template<typename T,
typename P,
typename M = NonCopyablePersistentTraits<T> >
class WeakReferenceCallbacks {
public:
typedef void (*Revivable)(Isolate* isolate,
Persistent<T, M>* object,
P* parameter);
};
/**
* An object reference that is independent of any handle scope. Where
* a Local handle only lives as long as the HandleScope in which it was
@ -701,9 +689,6 @@ template <class T, class M> class Persistent : public PersistentBase<T> {
if (M::kResetInDestructor) this->Reset();
}
V8_DEPRECATED("Use Reset instead",
V8_INLINE void Dispose()) { this->Reset(); }
// TODO(dcarney): this is pretty useless, fix or remove
template <class S>
V8_INLINE static Persistent<T>& Cast(Persistent<S>& that) { // NOLINT
@ -720,26 +705,9 @@ template <class T, class M> class Persistent : public PersistentBase<T> {
return Persistent<S>::Cast(*this);
}
template<typename S, typename P>
V8_DEPRECATED(
"Use SetWeak instead",
V8_INLINE void MakeWeak(
P* parameter,
typename WeakReferenceCallbacks<S, P>::Revivable callback));
template<typename P>
V8_DEPRECATED(
"Use SetWeak instead",
V8_INLINE void MakeWeak(
P* parameter,
typename WeakReferenceCallbacks<T, P>::Revivable callback));
// This will be removed.
V8_INLINE T* ClearAndLeak();
V8_DEPRECATED("This will be removed",
V8_INLINE void Clear()) { this->val_ = 0; }
// TODO(dcarney): remove
#ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
@ -852,10 +820,6 @@ class V8_EXPORT HandleScope {
~HandleScope();
template <class T>
V8_DEPRECATED("Use EscapableHandleScope::Escape instead",
Local<T> Close(Handle<T> value));
/**
* Counts the number of allocated handles.
*/
@ -894,18 +858,10 @@ class V8_EXPORT HandleScope {
}
};
void Leave();
internal::Isolate* isolate_;
internal::Object** prev_next_;
internal::Object** prev_limit_;
// TODO(dcarney): remove this field
// Allow for the active closing of HandleScopes which allows to pass a handle
// from the HandleScope being closed to the next top most HandleScope.
bool is_closed_;
internal::Object** RawClose(internal::Object** value);
friend class ImplementationUtilities;
friend class EscapableHandleScope;
template<class F> friend class Handle;
@ -1144,11 +1100,6 @@ class V8_EXPORT Script {
*/
Local<Value> Run();
/**
* Returns the script id value.
*/
V8_DEPRECATED("Use GetId instead", Local<Value> Id());
/**
* Returns the script id.
*/
@ -1240,8 +1191,6 @@ class V8_EXPORT Message {
// TODO(1245381): Print to a string instead of on a FILE.
static void PrintCurrentStackTrace(Isolate* isolate, FILE* out);
V8_DEPRECATED("Will be removed",
static void PrintCurrentStackTrace(FILE* out));
static const int kNoLineNumberInfo = 0;
static const int kNoColumnInfo = 0;
@ -1299,9 +1248,6 @@ class V8_EXPORT StackTrace {
Isolate* isolate,
int frame_limit,
StackTraceOptions options = kOverview);
V8_DEPRECATED("Will be removed",
static Local<StackTrace> CurrentStackTrace(
int frame_limit, StackTraceOptions options = kOverview));
};
@ -1633,8 +1579,6 @@ class V8_EXPORT Boolean : public Primitive {
public:
bool Value() const;
V8_INLINE static Handle<Boolean> New(Isolate* isolate, bool value);
V8_DEPRECATED("Will be removed",
V8_INLINE static Handle<Boolean> New(bool value));
};
@ -1840,30 +1784,6 @@ class V8_EXPORT String : public Primitive {
V8_INLINE static String* Cast(v8::Value* obj);
/**
* Allocates a new string from either UTF-8 encoded or ASCII data.
* The second parameter 'length' gives the buffer length. If omitted,
* the function calls 'strlen' to determine the buffer length.
*/
V8_DEPRECATED(
"Use NewFromUtf8 instead",
V8_INLINE static Local<String> New(const char* data, int length = -1));
/** Allocates a new string from 16-bit character codes.*/
V8_DEPRECATED(
"Use NewFromTwoByte instead",
V8_INLINE static Local<String> New(
const uint16_t* data, int length = -1));
/**
* Creates an internalized string (historically called a "symbol",
* not to be confused with ES6 symbols). Returns one if it exists already.
*/
V8_DEPRECATED(
"Use NewFromUtf8 instead",
V8_INLINE static Local<String> NewSymbol(
const char* data, int length = -1));
enum NewStringType {
kNormalString, kInternalizedString, kUndetectableString
};
@ -1904,8 +1824,6 @@ class V8_EXPORT String : public Primitive {
*/
static Local<String> NewExternal(Isolate* isolate,
ExternalStringResource* resource);
V8_DEPRECATED("Will be removed", static Local<String> NewExternal(
ExternalStringResource* resource));
/**
* Associate an external string resource with this string by transforming it
@ -1928,8 +1846,6 @@ class V8_EXPORT String : public Primitive {
*/
static Local<String> NewExternal(Isolate* isolate,
ExternalAsciiStringResource* resource);
V8_DEPRECATED("Will be removed", static Local<String> NewExternal(
ExternalAsciiStringResource* resource));
/**
* Associate an external string resource with this string by transforming it
@ -1947,18 +1863,6 @@ class V8_EXPORT String : public Primitive {
*/
bool CanMakeExternal();
/** Creates an undetectable string from the supplied ASCII or UTF-8 data.*/
V8_DEPRECATED(
"Use NewFromUtf8 instead",
V8_INLINE static Local<String> NewUndetectable(const char* data,
int length = -1));
/** Creates an undetectable string from the supplied 16-bit character codes.*/
V8_DEPRECATED(
"Use NewFromTwoByte instead",
V8_INLINE static Local<String> NewUndetectable(const uint16_t* data,
int length = -1));
/**
* Converts an object to a UTF-8-encoded character array. Useful if
* you want to print the object. If conversion to a string fails
@ -1982,30 +1886,6 @@ class V8_EXPORT String : public Primitive {
void operator=(const Utf8Value&);
};
/**
* Converts an object to an ASCII string.
* Useful if you want to print the object.
* If conversion to a string fails (eg. due to an exception in the toString()
* method of the object) then the length() method returns 0 and the * operator
* returns NULL.
*/
class V8_EXPORT AsciiValue {
public:
V8_DEPRECATED("Use Utf8Value instead",
explicit AsciiValue(Handle<v8::Value> obj));
~AsciiValue();
char* operator*() { return str_; }
const char* operator*() const { return str_; }
int length() const { return length_; }
private:
char* str_;
int length_;
// Disallow copying and assigning.
AsciiValue(const AsciiValue&);
void operator=(const AsciiValue&);
};
/**
* Converts an object to a two-byte string.
* If conversion to a string fails (eg. due to an exception in the toString()
@ -2487,7 +2367,6 @@ class V8_EXPORT Array : public Object {
* is negative the returned array will have length 0.
*/
static Local<Array> New(Isolate* isolate, int length = 0);
V8_DEPRECATED("Will be removed", static Local<Array> New(int length = 0));
V8_INLINE static Array* Cast(Value* obj);
private:
@ -2655,11 +2534,6 @@ class V8_EXPORT Function : public Object {
*/
bool IsBuiltin() const;
/**
* Returns scriptId object.
*/
V8_DEPRECATED("Use ScriptId instead", Handle<Value> GetScriptId() const);
/**
* Returns scriptId.
*/
@ -2751,8 +2625,6 @@ class V8_EXPORT ArrayBuffer : public Object {
* unless the object is externalized.
*/
static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length);
V8_DEPRECATED("Will be removed",
static Local<ArrayBuffer> New(size_t byte_length));
/**
* Create a new ArrayBuffer over an existing memory block.
@ -2762,8 +2634,6 @@ class V8_EXPORT ArrayBuffer : public Object {
*/
static Local<ArrayBuffer> New(Isolate* isolate, void* data,
size_t byte_length);
V8_DEPRECATED("Will be removed",
static Local<ArrayBuffer> New(void* data, size_t byte_length));
/**
* Returns true if ArrayBuffer is extrenalized, that is, does not
@ -3024,11 +2894,6 @@ class V8_EXPORT DataView : public ArrayBufferView {
class V8_EXPORT Date : public Object {
public:
static Local<Value> New(Isolate* isolate, double time);
V8_DEPRECATED("Will be removed", static Local<Value> New(double time));
V8_DEPRECATED(
"Use ValueOf instead",
double NumberValue() const) { return ValueOf(); }
/**
* A specialization of Value::NumberValue that is more efficient
@ -3051,8 +2916,6 @@ class V8_EXPORT Date : public Object {
* negatively impact the performance of date operations.
*/
static void DateTimeConfigurationChangeNotification(Isolate* isolate);
V8_DEPRECATED("Will be removed",
static void DateTimeConfigurationChangeNotification());
private:
static void CheckCast(v8::Value* obj);
@ -3065,15 +2928,7 @@ class V8_EXPORT Date : public Object {
class V8_EXPORT NumberObject : public Object {
public:
static Local<Value> New(Isolate* isolate, double value);
V8_DEPRECATED("Will be removed", static Local<Value> New(double value));
V8_DEPRECATED(
"Use ValueOf instead",
double NumberValue() const) { return ValueOf(); }
/**
* Returns the Number held by the object.
*/
double ValueOf() const;
V8_INLINE static NumberObject* Cast(v8::Value* obj);
@ -3090,13 +2945,6 @@ class V8_EXPORT BooleanObject : public Object {
public:
static Local<Value> New(bool value);
V8_DEPRECATED(
"Use ValueOf instead",
bool BooleanValue() const) { return ValueOf(); }
/**
* Returns the Boolean held by the object.
*/
bool ValueOf() const;
V8_INLINE static BooleanObject* Cast(v8::Value* obj);
@ -3113,13 +2961,6 @@ class V8_EXPORT StringObject : public Object {
public:
static Local<Value> New(Handle<String> value);
V8_DEPRECATED(
"Use ValueOf instead",
Local<String> StringValue() const) { return ValueOf(); }
/**
* Returns the String held by the object.
*/
Local<String> ValueOf() const;
V8_INLINE static StringObject* Cast(v8::Value* obj);
@ -3138,13 +2979,6 @@ class V8_EXPORT SymbolObject : public Object {
public:
static Local<Value> New(Isolate* isolate, Handle<Symbol> value);
V8_DEPRECATED(
"Use ValueOf instead",
Local<Symbol> SymbolValue() const) { return ValueOf(); }
/**
* Returns the Symbol held by the object.
*/
Local<Symbol> ValueOf() const;
V8_INLINE static SymbolObject* Cast(v8::Value* obj);
@ -3207,7 +3041,6 @@ class V8_EXPORT RegExp : public Object {
class V8_EXPORT External : public Value {
public:
static Local<External> New(Isolate* isolate, void* value);
V8_DEPRECATED("Will be removed", static Local<External> New(void *value));
V8_INLINE static External* Cast(Value* obj);
void* Value() const;
private:
@ -3227,8 +3060,6 @@ class V8_EXPORT Template : public Data {
void Set(Handle<String> name, Handle<Data> value,
PropertyAttribute attributes = None);
V8_INLINE void Set(Isolate* isolate, const char* name, Handle<Data> value);
V8_DEPRECATED("Will be removed",
V8_INLINE void Set(const char* name, Handle<Data> value));
void SetAccessorProperty(
Local<String> name,
@ -3764,12 +3595,6 @@ class V8_EXPORT Signature : public Data {
Handle<FunctionTemplate>(),
int argc = 0,
Handle<FunctionTemplate> argv[] = 0);
V8_DEPRECATED("Will be removed",
static Local<Signature> New(Handle<FunctionTemplate> receiver =
Handle<FunctionTemplate>(),
int argc = 0,
Handle<FunctionTemplate> argv[] =
0));
private:
Signature();
@ -3785,9 +3610,6 @@ class V8_EXPORT AccessorSignature : public Data {
static Local<AccessorSignature> New(Isolate* isolate,
Handle<FunctionTemplate> receiver =
Handle<FunctionTemplate>());
V8_DEPRECATED("Will be removed", static Local<AccessorSignature> New(
Handle<FunctionTemplate> receiver =
Handle<FunctionTemplate>()));
private:
AccessorSignature();
@ -3894,16 +3716,6 @@ class V8_EXPORT Extension { // NOLINT
virtual ~Extension() { }
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate(
v8::Isolate* isolate, v8::Handle<v8::String> name) {
#if defined(V8_DEPRECATION_WARNINGS)
return v8::Handle<v8::FunctionTemplate>();
#else
return GetNativeFunction(name);
#endif
}
V8_DEPRECATED("Will be removed",
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
v8::Handle<v8::String> name)) {
return v8::Handle<v8::FunctionTemplate>();
}
@ -3951,11 +3763,6 @@ V8_INLINE Handle<Primitive> Null(Isolate* isolate);
V8_INLINE Handle<Boolean> True(Isolate* isolate);
V8_INLINE Handle<Boolean> False(Isolate* isolate);
V8_DEPRECATED("Will be removed", Handle<Primitive> V8_EXPORT Undefined());
V8_DEPRECATED("Will be removed", Handle<Primitive> V8_EXPORT Null());
V8_DEPRECATED("Will be removed", Handle<Boolean> V8_EXPORT True());
V8_DEPRECATED("Will be removed", Handle<Boolean> V8_EXPORT False());
/**
* A set of constraints that specifies the limits of the runtime's memory use.
@ -3981,8 +3788,6 @@ class V8_EXPORT ResourceConstraints {
*/
void ConfigureDefaults(uint64_t physical_memory,
uint32_t number_of_processors);
V8_DEPRECATED("Will be removed",
void ConfigureDefaults(uint64_t physical_memory));
int max_young_space_size() const { return max_young_space_size_; }
void set_max_young_space_size(int value) { max_young_space_size_ = value; }
@ -4024,10 +3829,6 @@ typedef void (*FatalErrorCallback)(const char* location, const char* message);
typedef void (*MessageCallback)(Handle<Message> message, Handle<Value> error);
V8_DEPRECATED(
"Use Isolate::ThrowException instead",
Handle<Value> V8_EXPORT ThrowException(Handle<Value> exception));
/**
* Create new error objects by calling the corresponding error object
* constructor with the message.
@ -4220,10 +4021,6 @@ class V8_EXPORT Isolate {
*/
void Dispose();
V8_DEPRECATED("Use SetData(0, data) instead.",
V8_INLINE void SetData(void* data));
V8_DEPRECATED("Use GetData(0) instead.", V8_INLINE void* GetData());
/**
* Associate embedder-specific data with the isolate. |slot| has to be
* between 0 and GetNumberOfDataSlots() - 1.
@ -4841,11 +4638,6 @@ class V8_EXPORT V8 {
static void SetJitCodeEventHandler(JitCodeEventOptions options,
JitCodeEventHandler event_handler);
V8_DEPRECATED(
"Use Isolate::AdjustAmountOfExternalAllocatedMemory instead",
static int64_t AdjustAmountOfExternalAllocatedMemory(
int64_t change_in_bytes));
/**
* Forcefully terminate the current thread of JavaScript execution
* in the given isolate. If no isolate is provided, the default
@ -4975,12 +4767,10 @@ class V8_EXPORT V8 {
internal::Object** handle);
static internal::Object** CopyPersistent(internal::Object** handle);
static void DisposeGlobal(internal::Object** global_handle);
typedef WeakReferenceCallbacks<Value, void>::Revivable RevivableCallback;
typedef WeakCallbackData<Value, void>::Callback WeakCallback;
static void MakeWeak(internal::Object** global_handle,
void* data,
WeakCallback weak_callback,
RevivableCallback weak_reference_callback);
WeakCallback weak_callback);
static void ClearWeak(internal::Object** global_handle);
static void Eternalize(Isolate* isolate,
Value* handle,
@ -5193,15 +4983,6 @@ class V8_EXPORT Context {
Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(),
Handle<Value> global_object = Handle<Value>());
V8_DEPRECATED("Use Isolate::GetEnteredContext instead",
static Local<Context> GetEntered());
V8_DEPRECATED("Use Isolate::GetCurrentContext instead",
static Local<Context> GetCurrent());
V8_DEPRECATED("Use Isolate::GetCallingContext instead",
static Local<Context> GetCalling());
/**
* Sets the security token for the context. To access an object in
* another context, the security tokens must match.
@ -5231,9 +5012,6 @@ class V8_EXPORT Context {
/** Returns true if the context has experienced an out of memory situation. */
bool HasOutOfMemoryException();
V8_DEPRECATED("Use Isolate::InContext instead",
static bool InContext());
/** Returns an isolate associated with a current context. */
v8::Isolate* GetIsolate();
@ -5303,12 +5081,6 @@ class V8_EXPORT Context {
explicit V8_INLINE Scope(Handle<Context> context) : context_(context) {
context_->Enter();
}
V8_DEPRECATED(
"Use Handle version instead",
V8_INLINE Scope(Isolate* isolate, Persistent<Context>& context)) // NOLINT
: context_(Handle<Context>::New(isolate, context)) {
context_->Enter();
}
V8_INLINE ~Scope() { context_->Exit(); }
private:
@ -5894,8 +5666,7 @@ void PersistentBase<T>::SetWeak(
typedef typename WeakCallbackData<Value, void>::Callback Callback;
V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_),
parameter,
reinterpret_cast<Callback>(callback),
NULL);
reinterpret_cast<Callback>(callback));
}
@ -5908,29 +5679,6 @@ void PersistentBase<T>::SetWeak(
}
template <class T, class M>
template <typename S, typename P>
void Persistent<T, M>::MakeWeak(
P* parameters,
typename WeakReferenceCallbacks<S, P>::Revivable callback) {
TYPE_CHECK(S, T);
typedef typename WeakReferenceCallbacks<Value, void>::Revivable Revivable;
V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_),
parameters,
NULL,
reinterpret_cast<Revivable>(callback));
}
template <class T, class M>
template <typename P>
void Persistent<T, M>::MakeWeak(
P* parameters,
typename WeakReferenceCallbacks<T, P>::Revivable callback) {
MakeWeak<T, P>(parameters, callback);
}
template <class T>
void PersistentBase<T>::ClearWeak() {
V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_));
@ -6155,13 +5903,6 @@ int FunctionCallbackInfo<T>::Length() const {
}
template <class T>
Local<T> HandleScope::Close(Handle<T> value) {
internal::Object** before = reinterpret_cast<internal::Object**>(*value);
internal::Object** after = RawClose(before);
return Local<T>(reinterpret_cast<T*>(after));
}
Handle<Value> ScriptOrigin::ResourceName() const {
return resource_name_;
}
@ -6186,21 +5927,11 @@ Handle<Boolean> Boolean::New(Isolate* isolate, bool value) {
}
Handle<Boolean> Boolean::New(bool value) {
return Boolean::New(Isolate::GetCurrent(), value);
}
void Template::Set(Isolate* isolate, const char* name, v8::Handle<Data> value) {
Set(v8::String::NewFromUtf8(isolate, name), value);
}
void Template::Set(const char* name, v8::Handle<Data> value) {
Set(Isolate::GetCurrent(), name, value);
}
Local<Value> Object::GetInternalField(int index) {
#ifndef V8_ENABLE_CHECKS
typedef internal::Object O;
@ -6253,32 +5984,6 @@ Local<String> String::Empty(Isolate* isolate) {
}
Local<String> String::New(const char* data, int length) {
return NewFromUtf8(Isolate::GetCurrent(), data, kNormalString, length);
}
Local<String> String::New(const uint16_t* data, int length) {
return NewFromTwoByte(Isolate::GetCurrent(), data, kNormalString, length);
}
Local<String> String::NewSymbol(const char* data, int length) {
return NewFromUtf8(Isolate::GetCurrent(), data, kInternalizedString, length);
}
Local<String> String::NewUndetectable(const char* data, int length) {
return NewFromUtf8(Isolate::GetCurrent(), data, kUndetectableString, length);
}
Local<String> String::NewUndetectable(const uint16_t* data, int length) {
return NewFromTwoByte(
Isolate::GetCurrent(), data, kUndetectableString, length);
}
String::ExternalStringResource* String::GetExternalStringResource() const {
typedef internal::Object O;
typedef internal::Internals I;
@ -6649,18 +6354,6 @@ Handle<Boolean> False(Isolate* isolate) {
}
void Isolate::SetData(void* data) {
typedef internal::Internals I;
I::SetEmbedderData(this, 0, data);
}
void* Isolate::GetData() {
typedef internal::Internals I;
return I::GetEmbedderData(this, 0);
}
void Isolate::SetData(uint32_t slot, void* data) {
typedef internal::Internals I;
I::SetEmbedderData(this, slot, data);

View File

@ -246,16 +246,15 @@ AllocationTracker::UnresolvedLocation::UnresolvedLocation(
info_(info) {
script_ = Handle<Script>::cast(
script->GetIsolate()->global_handles()->Create(script));
GlobalHandles::MakeWeak(
reinterpret_cast<Object**>(script_.location()),
this, &HandleWeakScript);
GlobalHandles::MakeWeak(reinterpret_cast<Object**>(script_.location()),
this,
&HandleWeakScript);
}
AllocationTracker::UnresolvedLocation::~UnresolvedLocation() {
if (!script_.is_null()) {
script_->GetIsolate()->global_handles()->Destroy(
reinterpret_cast<Object**>(script_.location()));
GlobalHandles::Destroy(reinterpret_cast<Object**>(script_.location()));
}
}
@ -268,12 +267,11 @@ void AllocationTracker::UnresolvedLocation::Resolve() {
void AllocationTracker::UnresolvedLocation::HandleWeakScript(
v8::Isolate* isolate,
v8::Persistent<v8::Value>* obj,
void* data) {
UnresolvedLocation* location = reinterpret_cast<UnresolvedLocation*>(data);
location->script_ = Handle<Script>::null();
obj->Reset();
const v8::WeakCallbackData<v8::Value, void>& data) {
UnresolvedLocation* loc =
reinterpret_cast<UnresolvedLocation*>(data.GetParameter());
GlobalHandles::Destroy(reinterpret_cast<Object**>(loc->script_.location()));
loc->script_ = Handle<Script>::null();
}

View File

@ -112,9 +112,9 @@ class AllocationTracker {
void Resolve();
private:
static void HandleWeakScript(v8::Isolate* isolate,
v8::Persistent<v8::Value>* obj,
void* data);
static void HandleWeakScript(
const v8::WeakCallbackData<v8::Value, void>& data);
Handle<Script> script_;
int start_position_;
FunctionInfo* info_;

View File

@ -472,11 +472,6 @@ void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
}
v8::Handle<Value> ThrowException(v8::Handle<v8::Value> value) {
return v8::Isolate::GetCurrent()->ThrowException(value);
}
RegisteredExtension* RegisteredExtension::first_extension_ = NULL;
@ -523,42 +518,6 @@ Extension::Extension(const char* name,
}
v8::Handle<Primitive> Undefined() {
i::Isolate* isolate = i::Isolate::Current();
if (!EnsureInitializedForIsolate(isolate, "v8::Undefined()")) {
return v8::Handle<v8::Primitive>();
}
return ToApiHandle<Primitive>(isolate->factory()->undefined_value());
}
v8::Handle<Primitive> Null() {
i::Isolate* isolate = i::Isolate::Current();
if (!EnsureInitializedForIsolate(isolate, "v8::Null()")) {
return v8::Handle<v8::Primitive>();
}
return ToApiHandle<Primitive>(isolate->factory()->null_value());
}
v8::Handle<Boolean> True() {
i::Isolate* isolate = i::Isolate::Current();
if (!EnsureInitializedForIsolate(isolate, "v8::True()")) {
return v8::Handle<Boolean>();
}
return ToApiHandle<Boolean>(isolate->factory()->true_value());
}
v8::Handle<Boolean> False() {
i::Isolate* isolate = i::Isolate::Current();
if (!EnsureInitializedForIsolate(isolate, "v8::False()")) {
return v8::Handle<Boolean>();
}
return ToApiHandle<Boolean>(isolate->factory()->false_value());
}
ResourceConstraints::ResourceConstraints()
: max_young_space_size_(0),
max_old_space_size_(0),
@ -605,11 +564,6 @@ void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory,
}
void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory) {
ConfigureDefaults(physical_memory, i::CPU::NumberOfProcessorsOnline());
}
bool SetResourceConstraints(Isolate* v8_isolate,
ResourceConstraints* constraints) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
@ -655,12 +609,8 @@ i::Object** V8::CopyPersistent(i::Object** obj) {
void V8::MakeWeak(i::Object** object,
void* parameters,
WeakCallback weak_callback,
RevivableCallback weak_reference_callback) {
i::GlobalHandles::MakeWeak(object,
parameters,
weak_callback,
weak_reference_callback);
WeakCallback weak_callback) {
i::GlobalHandles::MakeWeak(object, parameters, weak_callback);
}
@ -703,20 +653,12 @@ void HandleScope::Initialize(Isolate* isolate) {
isolate_ = internal_isolate;
prev_next_ = current->next;
prev_limit_ = current->limit;
is_closed_ = false;
current->level++;
}
HandleScope::~HandleScope() {
if (!is_closed_) {
Leave();
}
}
void HandleScope::Leave() {
return i::HandleScope::CloseScope(isolate_, prev_next_, prev_limit_);
i::HandleScope::CloseScope(isolate_, prev_next_, prev_limit_);
}
@ -859,32 +801,6 @@ void Context::SetAlignedPointerInEmbedderData(int index, void* value) {
}
i::Object** v8::HandleScope::RawClose(i::Object** value) {
if (!ApiCheck(!is_closed_,
"v8::HandleScope::Close()",
"Local scope has already been closed")) {
return 0;
}
LOG_API(isolate_, "CloseHandleScope");
// Read the result before popping the handle block.
i::Object* result = NULL;
if (value != NULL) {
result = *value;
}
is_closed_ = true;
Leave();
if (value == NULL) {
return NULL;
}
// Allocate a new handle on the previous handle block.
i::Handle<i::Object> handle(result, isolate_);
return handle.location();
}
// --- N e a n d e r ---
@ -1124,12 +1040,6 @@ Local<Signature> Signature::New(Isolate* isolate,
}
Local<Signature> Signature::New(Handle<FunctionTemplate> receiver,
int argc, Handle<FunctionTemplate> argv[]) {
return New(Isolate::GetCurrent(), receiver, argc, argv);
}
Local<AccessorSignature> AccessorSignature::New(
Isolate* isolate,
Handle<FunctionTemplate> receiver) {
@ -1137,13 +1047,6 @@ Local<AccessorSignature> AccessorSignature::New(
}
// While this is just a cast, it's lame not to use an Isolate parameter.
Local<AccessorSignature> AccessorSignature::New(
Handle<FunctionTemplate> receiver) {
return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver));
}
template<typename Operation>
static Local<Operation> NewDescriptor(
Isolate* isolate,
@ -1920,25 +1823,6 @@ static i::Handle<i::SharedFunctionInfo> OpenScript(Script* script) {
}
Local<Value> Script::Id() {
i::Handle<i::HeapObject> obj =
i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this));
i::Isolate* isolate = obj->GetIsolate();
ON_BAILOUT(isolate, "v8::Script::Id()", return Local<Value>());
LOG_API(isolate, "Script::Id");
i::Object* raw_id = NULL;
{
i::HandleScope scope(isolate);
i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this);
i::Handle<i::Script> script(i::Script::cast(function_info->script()));
i::Handle<i::Object> id(script->id(), isolate);
raw_id = *id;
}
i::Handle<i::Object> id(raw_id, isolate);
return Utils::ToLocal(id);
}
int Script::GetId() {
i::Handle<i::HeapObject> obj =
i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this));
@ -2321,11 +2205,6 @@ void Message::PrintCurrentStackTrace(Isolate* isolate, FILE* out) {
}
void Message::PrintCurrentStackTrace(FILE* out) {
PrintCurrentStackTrace(Isolate::GetCurrent(), out);
}
// --- S t a c k T r a c e ---
Local<StackFrame> StackTrace::GetFrame(uint32_t index) const {
@ -2365,12 +2244,6 @@ Local<StackTrace> StackTrace::CurrentStackTrace(
}
Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit,
StackTraceOptions options) {
return CurrentStackTrace(Isolate::GetCurrent(), frame_limit, options);
}
// --- S t a c k F r a m e ---
int StackFrame::GetLineNumber() const {
@ -4286,17 +4159,6 @@ bool Function::IsBuiltin() const {
}
Handle<Value> Function::GetScriptId() const {
i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
i::Isolate* isolate = func->GetIsolate();
if (!func->shared()->script()->IsScript()) {
return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
}
i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
return Utils::ToLocal(i::Handle<i::Object>(script->id(), isolate));
}
int Function::ScriptId() const {
i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
if (!func->shared()->script()->IsScript()) return v8::Script::kNoScriptId;
@ -5373,38 +5235,12 @@ bool Context::HasOutOfMemoryException() {
}
bool Context::InContext() {
return i::Isolate::Current()->context() != NULL;
}
v8::Isolate* Context::GetIsolate() {
i::Handle<i::Context> env = Utils::OpenHandle(this);
return reinterpret_cast<Isolate*>(env->GetIsolate());
}
v8::Local<v8::Context> Context::GetEntered() {
i::Isolate* isolate = i::Isolate::Current();
if (!EnsureInitializedForIsolate(isolate, "v8::Context::GetEntered()")) {
return Local<Context>();
}
return reinterpret_cast<Isolate*>(isolate)->GetEnteredContext();
}
v8::Local<v8::Context> Context::GetCurrent() {
i::Isolate* isolate = i::Isolate::Current();
return reinterpret_cast<Isolate*>(isolate)->GetCurrentContext();
}
v8::Local<v8::Context> Context::GetCalling() {
i::Isolate* isolate = i::Isolate::Current();
return reinterpret_cast<Isolate*>(isolate)->GetCallingContext();
}
v8::Local<v8::Object> Context::Global() {
i::Handle<i::Context> context = Utils::OpenHandle(this);
i::Isolate* isolate = context->GetIsolate();
@ -5499,11 +5335,6 @@ Local<External> v8::External::New(Isolate* isolate, void* value) {
}
Local<External> v8::External::New(void* value) {
return v8::External::New(Isolate::GetCurrent(), value);
}
void* External::Value() const {
return ExternalValue(*Utils::OpenHandle(this));
}
@ -5695,12 +5526,6 @@ Local<String> v8::String::NewExternal(
}
Local<String> v8::String::NewExternal(
v8::String::ExternalStringResource* resource) {
return NewExternal(Isolate::GetCurrent(), resource);
}
bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
i::Handle<i::String> obj = Utils::OpenHandle(this);
i::Isolate* isolate = obj->GetIsolate();
@ -5752,12 +5577,6 @@ Local<String> v8::String::NewExternal(
}
Local<String> v8::String::NewExternal(
v8::String::ExternalAsciiStringResource* resource) {
return NewExternal(Isolate::GetCurrent(), resource);
}
bool v8::String::MakeExternal(
v8::String::ExternalAsciiStringResource* resource) {
i::Handle<i::String> obj = Utils::OpenHandle(this);
@ -5840,11 +5659,6 @@ Local<v8::Value> v8::NumberObject::New(Isolate* isolate, double value) {
}
Local<v8::Value> v8::NumberObject::New(double value) {
return New(Isolate::GetCurrent(), value);
}
double v8::NumberObject::ValueOf() const {
i::Isolate* isolate = i::Isolate::Current();
LOG_API(isolate, "NumberObject::NumberValue");
@ -5936,11 +5750,6 @@ Local<v8::Value> v8::Date::New(Isolate* isolate, double time) {
}
Local<v8::Value> v8::Date::New(double time) {
return New(Isolate::GetCurrent(), time);
}
double v8::Date::ValueOf() const {
i::Isolate* isolate = i::Isolate::Current();
LOG_API(isolate, "Date::NumberValue");
@ -5986,11 +5795,6 @@ void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) {
}
void v8::Date::DateTimeConfigurationChangeNotification() {
DateTimeConfigurationChangeNotification(Isolate::GetCurrent());
}
static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) {
i::Isolate* isolate = i::Isolate::Current();
uint8_t flags_buf[3];
@ -6056,11 +5860,6 @@ Local<v8::Array> v8::Array::New(Isolate* isolate, int length) {
}
Local<v8::Array> v8::Array::New(int length) {
return New(Isolate::GetCurrent(), length);
}
uint32_t v8::Array::Length() const {
i::Handle<i::JSArray> obj = Utils::OpenHandle(this);
i::Object* length = obj->length();
@ -6156,11 +5955,6 @@ Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) {
}
Local<ArrayBuffer> v8::ArrayBuffer::New(size_t byte_length) {
return New(Isolate::GetCurrent(), byte_length);
}
Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data,
size_t byte_length) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
@ -6174,11 +5968,6 @@ Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data,
}
Local<ArrayBuffer> v8::ArrayBuffer::New(void* data, size_t byte_length) {
return New(Isolate::GetCurrent(), data, byte_length);
}
Local<ArrayBuffer> v8::ArrayBufferView::Buffer() {
i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
ASSERT(obj->buffer()->IsJSArrayBuffer());
@ -6511,16 +6300,6 @@ int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
}
int64_t V8::AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes) {
i::Isolate* isolate = i::Isolate::UncheckedCurrent();
if (isolate == NULL || !isolate->IsInitialized()) {
return 0;
}
Isolate* isolate_ext = reinterpret_cast<Isolate*>(isolate);
return isolate_ext->AdjustAmountOfExternalAllocatedMemory(change_in_bytes);
}
HeapProfiler* Isolate::GetHeapProfiler() {
i::HeapProfiler* heap_profiler =
reinterpret_cast<i::Isolate*>(this)->heap_profiler();
@ -6793,27 +6572,6 @@ String::Utf8Value::~Utf8Value() {
}
String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj)
: str_(NULL), length_(0) {
i::Isolate* isolate = i::Isolate::Current();
if (obj.IsEmpty()) return;
ENTER_V8(isolate);
i::HandleScope scope(isolate);
TryCatch try_catch;
Handle<String> str = obj->ToString();
if (str.IsEmpty()) return;
length_ = str->Utf8Length();
str_ = i::NewArray<char>(length_ + 1);
str->WriteUtf8(str_);
ASSERT(i::String::NonAsciiStart(str_, length_) >= length_);
}
String::AsciiValue::~AsciiValue() {
i::DeleteArray(str_);
}
String::Value::Value(v8::Handle<v8::Value> obj)
: str_(NULL), length_(0) {
i::Isolate* isolate = i::Isolate::Current();
@ -7527,16 +7285,6 @@ void HeapProfiler::SetRetainedObjectInfo(UniqueId id,
}
void HeapProfiler::StartRecordingHeapAllocations() {
reinterpret_cast<i::HeapProfiler*>(this)->StartHeapObjectsTracking(true);
}
void HeapProfiler::StopRecordingHeapAllocations() {
reinterpret_cast<i::HeapProfiler*>(this)->StopHeapObjectsTracking();
}
v8::Testing::StressType internal::Testing::stress_type_ =
v8::Testing::kStressTypeOpt;

View File

@ -646,11 +646,10 @@ void ScriptCache::Add(Handle<Script> script) {
// Globalize the script object, make it weak and use the location of the
// global handle as the value in the hash map.
Handle<Script> script_ =
Handle<Script>::cast(
(global_handles->Create(*script)));
global_handles->MakeWeak(reinterpret_cast<Object**>(script_.location()),
this,
ScriptCache::HandleWeakScript);
Handle<Script>::cast(global_handles->Create(*script));
GlobalHandles::MakeWeak(reinterpret_cast<Object**>(script_.location()),
this,
ScriptCache::HandleWeakScript);
entry->value = script_.location();
}
@ -680,36 +679,37 @@ void ScriptCache::ProcessCollectedScripts() {
void ScriptCache::Clear() {
GlobalHandles* global_handles = isolate_->global_handles();
// Iterate the script cache to get rid of all the weak handles.
for (HashMap::Entry* entry = Start(); entry != NULL; entry = Next(entry)) {
ASSERT(entry != NULL);
Object** location = reinterpret_cast<Object**>(entry->value);
ASSERT((*location)->IsScript());
global_handles->ClearWeakness(location);
global_handles->Destroy(location);
GlobalHandles::ClearWeakness(location);
GlobalHandles::Destroy(location);
}
// Clear the content of the hash map.
HashMap::Clear();
}
void ScriptCache::HandleWeakScript(v8::Isolate* isolate,
v8::Persistent<v8::Value>* obj,
void* data) {
ScriptCache* script_cache = reinterpret_cast<ScriptCache*>(data);
// Find the location of the global handle.
Script** location =
reinterpret_cast<Script**>(Utils::OpenPersistent(*obj).location());
ASSERT((*location)->IsScript());
void ScriptCache::HandleWeakScript(
const v8::WeakCallbackData<v8::Value, void>& data) {
// Retrieve the script identifier.
Handle<Object> object = Utils::OpenHandle(*data.GetValue());
int id = Handle<Script>::cast(object)->id()->value();
void* key = reinterpret_cast<void*>(id);
uint32_t hash = Hash(id);
// Remove the entry from the cache.
int id = (*location)->id()->value();
script_cache->Remove(reinterpret_cast<void*>(id), Hash(id));
// Remove the corresponding entry from the cache.
ScriptCache* script_cache =
reinterpret_cast<ScriptCache*>(data.GetParameter());
HashMap::Entry* entry = script_cache->Lookup(key, hash, false);
Object** location = reinterpret_cast<Object**>(entry->value);
script_cache->Remove(key, hash);
script_cache->collected_scripts_.Add(id);
// Clear the weak handle.
obj->Reset();
GlobalHandles::Destroy(location);
}
@ -728,11 +728,11 @@ void Debug::SetUp(bool create_heap_objects) {
}
void Debug::HandleWeakDebugInfo(v8::Isolate* isolate,
v8::Persistent<v8::Value>* obj,
void* data) {
Debug* debug = reinterpret_cast<Isolate*>(isolate)->debug();
DebugInfoListNode* node = reinterpret_cast<DebugInfoListNode*>(data);
void Debug::HandleWeakDebugInfo(
const v8::WeakCallbackData<v8::Value, void>& data) {
Debug* debug = reinterpret_cast<Isolate*>(data.GetIsolate())->debug();
DebugInfoListNode* node =
reinterpret_cast<DebugInfoListNode*>(data.GetParameter());
// We need to clear all breakpoints associated with the function to restore
// original code and avoid patching the code twice later because
// the function will live in the heap until next gc, and can be found by
@ -741,29 +741,27 @@ void Debug::HandleWeakDebugInfo(v8::Isolate* isolate,
it.ClearAllDebugBreak();
debug->RemoveDebugInfo(node->debug_info());
#ifdef DEBUG
node = debug->debug_info_list_;
while (node != NULL) {
ASSERT(node != reinterpret_cast<DebugInfoListNode*>(data));
node = node->next();
for (DebugInfoListNode* n = debug->debug_info_list_;
n != NULL;
n = n->next()) {
ASSERT(n != node);
}
#endif
}
DebugInfoListNode::DebugInfoListNode(DebugInfo* debug_info): next_(NULL) {
GlobalHandles* global_handles = debug_info->GetIsolate()->global_handles();
// Globalize the request debug info object and make it weak.
debug_info_ = Handle<DebugInfo>::cast(
(global_handles->Create(debug_info)));
global_handles->MakeWeak(reinterpret_cast<Object**>(debug_info_.location()),
this,
Debug::HandleWeakDebugInfo);
GlobalHandles* global_handles = debug_info->GetIsolate()->global_handles();
debug_info_ = Handle<DebugInfo>::cast(global_handles->Create(debug_info));
GlobalHandles::MakeWeak(reinterpret_cast<Object**>(debug_info_.location()),
this,
Debug::HandleWeakDebugInfo);
}
DebugInfoListNode::~DebugInfoListNode() {
debug_info_->GetIsolate()->global_handles()->Destroy(
reinterpret_cast<Object**>(debug_info_.location()));
GlobalHandles::Destroy(reinterpret_cast<Object**>(debug_info_.location()));
}
@ -921,8 +919,7 @@ void Debug::Unload() {
DestroyScriptCache();
// Clear debugger context global handle.
isolate_->global_handles()->Destroy(
reinterpret_cast<Object**>(debug_context_.location()));
GlobalHandles::Destroy(reinterpret_cast<Object**>(debug_context_.location()));
debug_context_ = Handle<Context>();
}
@ -3249,12 +3246,12 @@ void Debugger::SetEventListener(Handle<Object> callback,
// Clear the global handles for the event listener and the event listener data
// object.
if (!event_listener_.is_null()) {
global_handles->Destroy(
GlobalHandles::Destroy(
reinterpret_cast<Object**>(event_listener_.location()));
event_listener_ = Handle<Object>();
}
if (!event_listener_data_.is_null()) {
global_handles->Destroy(
GlobalHandles::Destroy(
reinterpret_cast<Object**>(event_listener_data_.location()));
event_listener_data_ = Handle<Object>();
}

View File

@ -201,9 +201,8 @@ class ScriptCache : private HashMap {
void Clear();
// Weak handle callback for scripts in the cache.
static void HandleWeakScript(v8::Isolate* isolate,
v8::Persistent<v8::Value>* obj,
void* data);
static void HandleWeakScript(
const v8::WeakCallbackData<v8::Value, void>& data);
Isolate* isolate_;
// List used during GC to temporarily store id's of collected scripts.
@ -403,9 +402,8 @@ class Debug {
static const int kEstimatedNofBreakPointsInFunction = 16;
// Passed to MakeWeak.
static void HandleWeakDebugInfo(v8::Isolate* isolate,
v8::Persistent<v8::Value>* obj,
void* data);
static void HandleWeakDebugInfo(
const v8::WeakCallbackData<v8::Value, void>& data);
friend class Debugger;
friend Handle<FixedArray> GetDebuggedFunctions(); // In test-debug.cc

View File

@ -169,13 +169,6 @@ class GlobalHandles::Node {
flags_ = IsInNewSpaceList::update(flags_, v);
}
bool is_revivable_callback() {
return IsRevivableCallback::decode(flags_);
}
void set_revivable_callback(bool v) {
flags_ = IsRevivableCallback::update(flags_, v);
}
bool IsNearDeath() const {
// Check for PENDING to ensure correct answer when processing callbacks.
return state() == PENDING || state() == NEAR_DEATH;
@ -234,21 +227,12 @@ class GlobalHandles::Node {
parameter_or_next_free_.next_free = value;
}
void MakeWeak(void* parameter,
WeakCallback weak_callback,
RevivableCallback revivable_callback) {
ASSERT((weak_callback == NULL) != (revivable_callback == NULL));
void MakeWeak(void* parameter, WeakCallback weak_callback) {
ASSERT(weak_callback != NULL);
ASSERT(state() != FREE);
set_state(WEAK);
set_parameter(parameter);
if (weak_callback != NULL) {
weak_callback_ = weak_callback;
set_revivable_callback(false);
} else {
weak_callback_ =
reinterpret_cast<WeakCallback>(revivable_callback);
set_revivable_callback(true);
}
weak_callback_ = weak_callback;
}
void ClearWeakness() {
@ -278,20 +262,12 @@ class GlobalHandles::Node {
// Leaving V8.
VMState<EXTERNAL> state(isolate);
HandleScope handle_scope(isolate);
if (is_revivable_callback()) {
RevivableCallback revivable =
reinterpret_cast<RevivableCallback>(weak_callback_);
revivable(reinterpret_cast<v8::Isolate*>(isolate),
reinterpret_cast<Persistent<Value>*>(&object),
par);
} else {
Handle<Object> handle(*object, isolate);
v8::WeakCallbackData<v8::Value, void> data(
reinterpret_cast<v8::Isolate*>(isolate),
v8::Utils::ToLocal(handle),
par);
weak_callback_(data);
}
Handle<Object> handle(*object, isolate);
v8::WeakCallbackData<v8::Value, void> data(
reinterpret_cast<v8::Isolate*>(isolate),
v8::Utils::ToLocal(handle),
par);
weak_callback_(data);
}
// Absence of explicit cleanup or revival of weak handle
// in most of the cases would lead to memory leak.
@ -325,7 +301,6 @@ class GlobalHandles::Node {
class IsIndependent: public BitField<bool, 4, 1> {};
class IsPartiallyDependent: public BitField<bool, 5, 1> {};
class IsInNewSpaceList: public BitField<bool, 6, 1> {};
class IsRevivableCallback: public BitField<bool, 7, 1> {};
uint8_t flags_;
@ -522,10 +497,8 @@ void GlobalHandles::Destroy(Object** location) {
void GlobalHandles::MakeWeak(Object** location,
void* parameter,
WeakCallback weak_callback,
RevivableCallback revivable_callback) {
Node::FromLocation(location)->MakeWeak(
parameter, weak_callback, revivable_callback);
WeakCallback weak_callback) {
Node::FromLocation(location)->MakeWeak(parameter, weak_callback);
}

View File

@ -135,7 +135,6 @@ class GlobalHandles {
static void Destroy(Object** location);
typedef WeakCallbackData<v8::Value, void>::Callback WeakCallback;
typedef WeakReferenceCallbacks<v8::Value, void>::Revivable RevivableCallback;
// Make the global handle weak and set the callback parameter for the
// handle. When the garbage collector recognizes that only weak global
@ -145,14 +144,7 @@ class GlobalHandles {
// reason is that Smi::FromInt(0) does not change during garage collection.
static void MakeWeak(Object** location,
void* parameter,
WeakCallback weak_callback,
RevivableCallback revivable_callback);
static inline void MakeWeak(Object** location,
void* parameter,
RevivableCallback revivable_callback) {
MakeWeak(location, parameter, NULL, revivable_callback);
}
WeakCallback weak_callback);
void RecordStats(HeapStats* stats);

View File

@ -225,17 +225,15 @@ Handle<Object> LookupSingleCharacterStringFromCode(Isolate* isolate,
// collector will call the weak callback on the global handle
// associated with the wrapper and get rid of both the wrapper and the
// handle.
static void ClearWrapperCache(v8::Isolate* v8_isolate,
Persistent<v8::Value>* handle,
void*) {
Handle<Object> cache = Utils::OpenPersistent(handle);
JSValue* wrapper = JSValue::cast(*cache);
static void ClearWrapperCache(
const v8::WeakCallbackData<v8::Value, void>& data) {
Object** location = reinterpret_cast<Object**>(data.GetParameter());
JSValue* wrapper = JSValue::cast(*location);
Foreign* foreign = Script::cast(wrapper->value())->wrapper();
ASSERT(foreign->foreign_address() ==
reinterpret_cast<Address>(cache.location()));
ASSERT_EQ(foreign->foreign_address(), reinterpret_cast<Address>(location));
foreign->set_foreign_address(0);
Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
isolate->global_handles()->Destroy(cache.location());
GlobalHandles::Destroy(location);
Isolate* isolate = reinterpret_cast<Isolate*>(data.GetIsolate());
isolate->counters()->script_wrappers()->Decrement();
}
@ -267,9 +265,9 @@ Handle<JSValue> GetScriptWrapper(Handle<Script> script) {
// for future use. The cache will automatically be cleared by the
// garbage collector when it is not used anymore.
Handle<Object> handle = isolate->global_handles()->Create(*result);
isolate->global_handles()->MakeWeak(handle.location(),
NULL,
&ClearWrapperCache);
GlobalHandles::MakeWeak(handle.location(),
reinterpret_cast<void*>(handle.location()),
&ClearWrapperCache);
script->wrapper()->set_foreign_address(
reinterpret_cast<Address>(handle.location()));
return result;

View File

@ -864,15 +864,24 @@ icu::SimpleDateFormat* DateFormat::UnpackDateFormat(
}
void DateFormat::DeleteDateFormat(v8::Isolate* isolate,
Persistent<v8::Value>* object,
void* param) {
// First delete the hidden C++ object.
delete reinterpret_cast<icu::SimpleDateFormat*>(Handle<JSObject>::cast(
v8::Utils::OpenPersistent(object))->GetInternalField(0));
template<class T>
void DeleteNativeObjectAt(const v8::WeakCallbackData<v8::Value, void>& data,
int index) {
v8::Local<v8::Object> obj = v8::Handle<v8::Object>::Cast(data.GetValue());
delete reinterpret_cast<T*>(obj->GetAlignedPointerFromInternalField(index));
}
// Then dispose of the persistent handle to JS object.
object->Reset();
static void DestroyGlobalHandle(
const v8::WeakCallbackData<v8::Value, void>& data) {
GlobalHandles::Destroy(reinterpret_cast<Object**>(data.GetParameter()));
}
void DateFormat::DeleteDateFormat(
const v8::WeakCallbackData<v8::Value, void>& data) {
DeleteNativeObjectAt<icu::SimpleDateFormat>(data, 0);
DestroyGlobalHandle(data);
}
@ -928,15 +937,10 @@ icu::DecimalFormat* NumberFormat::UnpackNumberFormat(
}
void NumberFormat::DeleteNumberFormat(v8::Isolate* isolate,
Persistent<v8::Value>* object,
void* param) {
// First delete the hidden C++ object.
delete reinterpret_cast<icu::DecimalFormat*>(Handle<JSObject>::cast(
v8::Utils::OpenPersistent(object))->GetInternalField(0));
// Then dispose of the persistent handle to JS object.
object->Reset();
void NumberFormat::DeleteNumberFormat(
const v8::WeakCallbackData<v8::Value, void>& data) {
DeleteNativeObjectAt<icu::DecimalFormat>(data, 0);
DestroyGlobalHandle(data);
}
@ -989,15 +993,10 @@ icu::Collator* Collator::UnpackCollator(Isolate* isolate,
}
void Collator::DeleteCollator(v8::Isolate* isolate,
Persistent<v8::Value>* object,
void* param) {
// First delete the hidden C++ object.
delete reinterpret_cast<icu::Collator*>(Handle<JSObject>::cast(
v8::Utils::OpenPersistent(object))->GetInternalField(0));
// Then dispose of the persistent handle to JS object.
object->Reset();
void Collator::DeleteCollator(
const v8::WeakCallbackData<v8::Value, void>& data) {
DeleteNativeObjectAt<icu::Collator>(data, 0);
DestroyGlobalHandle(data);
}
@ -1053,18 +1052,11 @@ icu::BreakIterator* BreakIterator::UnpackBreakIterator(Isolate* isolate,
}
void BreakIterator::DeleteBreakIterator(v8::Isolate* isolate,
Persistent<v8::Value>* object,
void* param) {
// First delete the hidden C++ object.
delete reinterpret_cast<icu::BreakIterator*>(Handle<JSObject>::cast(
v8::Utils::OpenPersistent(object))->GetInternalField(0));
delete reinterpret_cast<icu::UnicodeString*>(Handle<JSObject>::cast(
v8::Utils::OpenPersistent(object))->GetInternalField(1));
// Then dispose of the persistent handle to JS object.
object->Reset();
void BreakIterator::DeleteBreakIterator(
const v8::WeakCallbackData<v8::Value, void>& data) {
DeleteNativeObjectAt<icu::BreakIterator>(data, 0);
DeleteNativeObjectAt<icu::UnicodeString>(data, 1);
DestroyGlobalHandle(data);
}
} } // namespace v8::internal

View File

@ -71,9 +71,9 @@ class DateFormat {
// Release memory we allocated for the DateFormat once the JS object that
// holds the pointer gets garbage collected.
static void DeleteDateFormat(v8::Isolate* isolate,
Persistent<v8::Value>* object,
void* param);
static void DeleteDateFormat(
const v8::WeakCallbackData<v8::Value, void>& data);
private:
DateFormat();
};
@ -95,9 +95,9 @@ class NumberFormat {
// Release memory we allocated for the NumberFormat once the JS object that
// holds the pointer gets garbage collected.
static void DeleteNumberFormat(v8::Isolate* isolate,
Persistent<v8::Value>* object,
void* param);
static void DeleteNumberFormat(
const v8::WeakCallbackData<v8::Value, void>& data);
private:
NumberFormat();
};
@ -118,9 +118,9 @@ class Collator {
// Release memory we allocated for the Collator once the JS object that holds
// the pointer gets garbage collected.
static void DeleteCollator(v8::Isolate* isolate,
Persistent<v8::Value>* object,
void* param);
static void DeleteCollator(
const v8::WeakCallbackData<v8::Value, void>& data);
private:
Collator();
};
@ -141,9 +141,8 @@ class BreakIterator {
// Release memory we allocated for the BreakIterator once the JS object that
// holds the pointer gets garbage collected.
static void DeleteBreakIterator(v8::Isolate* isolate,
Persistent<v8::Value>* object,
void* param);
static void DeleteBreakIterator(
const v8::WeakCallbackData<v8::Value, void>& data);
private:
BreakIterator();

View File

@ -9949,8 +9949,7 @@ class ArrayConcatVisitor {
}
inline void clear_storage() {
isolate_->global_handles()->Destroy(
Handle<Object>::cast(storage_).location());
GlobalHandles::Destroy(Handle<Object>::cast(storage_).location());
}
inline void set_storage(FixedArray* storage) {
@ -13806,8 +13805,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateDateTimeFormat) {
// Make object handle weak so we can delete the data format once GC kicks in.
Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
GlobalHandles::MakeWeak(reinterpret_cast<Object**>(wrapper.location()),
NULL,
GlobalHandles::MakeWeak(wrapper.location(),
reinterpret_cast<void*>(wrapper.location()),
DateFormat::DeleteDateFormat);
return *local_object;
}
@ -13910,8 +13909,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateNumberFormat) {
NONE));
Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
GlobalHandles::MakeWeak(reinterpret_cast<Object**>(wrapper.location()),
NULL,
GlobalHandles::MakeWeak(wrapper.location(),
reinterpret_cast<void*>(wrapper.location()),
NumberFormat::DeleteNumberFormat);
return *local_object;
}
@ -14022,8 +14021,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateCollator) {
NONE));
Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
GlobalHandles::MakeWeak(reinterpret_cast<Object**>(wrapper.location()),
NULL,
GlobalHandles::MakeWeak(wrapper.location(),
reinterpret_cast<void*>(wrapper.location()),
Collator::DeleteCollator);
return *local_object;
}
@ -14098,8 +14097,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateBreakIterator) {
// Make object handle weak so we can delete the break iterator once GC kicks
// in.
Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
GlobalHandles::MakeWeak(reinterpret_cast<Object**>(wrapper.location()),
NULL,
GlobalHandles::MakeWeak(wrapper.location(),
reinterpret_cast<void*>(wrapper.location()),
BreakIterator::DeleteBreakIterator);
return *local_object;
}

View File

@ -26,6 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdlib.h>
#include <utility>
#include "v8.h"
@ -382,22 +383,24 @@ TEST(GlobalHandles) {
CHECK((*h4)->IsHeapNumber());
CHECK_EQ(*h3, *h1);
global_handles->Destroy(h1.location());
global_handles->Destroy(h3.location());
GlobalHandles::Destroy(h1.location());
GlobalHandles::Destroy(h3.location());
CHECK_EQ(*h4, *h2);
global_handles->Destroy(h2.location());
global_handles->Destroy(h4.location());
GlobalHandles::Destroy(h2.location());
GlobalHandles::Destroy(h4.location());
}
static bool WeakPointerCleared = false;
static void TestWeakGlobalHandleCallback(v8::Isolate* isolate,
v8::Persistent<v8::Value>* handle,
void* id) {
if (1234 == reinterpret_cast<intptr_t>(id)) WeakPointerCleared = true;
handle->Reset();
static void TestWeakGlobalHandleCallback(
const v8::WeakCallbackData<v8::Value, void>& data) {
std::pair<v8::Persistent<v8::Value>*, int>* p =
reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>(
data.GetParameter());
if (p->second == 1234) WeakPointerCleared = true;
p->first->Reset();
}
@ -424,9 +427,10 @@ TEST(WeakGlobalHandlesScavenge) {
h2 = global_handles->Create(*u);
}
global_handles->MakeWeak(h2.location(),
reinterpret_cast<void*>(1234),
&TestWeakGlobalHandleCallback);
std::pair<Handle<Object>*, int> handle_and_id(&h2, 1234);
GlobalHandles::MakeWeak(h2.location(),
reinterpret_cast<void*>(&handle_and_id),
&TestWeakGlobalHandleCallback);
// Scavenge treats weak pointers as normal roots.
heap->PerformScavenge();
@ -438,8 +442,8 @@ TEST(WeakGlobalHandlesScavenge) {
CHECK(!global_handles->IsNearDeath(h2.location()));
CHECK(!global_handles->IsNearDeath(h1.location()));
global_handles->Destroy(h1.location());
global_handles->Destroy(h2.location());
GlobalHandles::Destroy(h1.location());
GlobalHandles::Destroy(h2.location());
}
@ -470,9 +474,10 @@ TEST(WeakGlobalHandlesMark) {
heap->CollectGarbage(NEW_SPACE);
CHECK(!heap->InNewSpace(*h1) && !heap->InNewSpace(*h2));
global_handles->MakeWeak(h2.location(),
reinterpret_cast<void*>(1234),
&TestWeakGlobalHandleCallback);
std::pair<Handle<Object>*, int> handle_and_id(&h2, 1234);
GlobalHandles::MakeWeak(h2.location(),
reinterpret_cast<void*>(&handle_and_id),
&TestWeakGlobalHandleCallback);
CHECK(!GlobalHandles::IsNearDeath(h1.location()));
CHECK(!GlobalHandles::IsNearDeath(h2.location()));
@ -484,7 +489,7 @@ TEST(WeakGlobalHandlesMark) {
CHECK(WeakPointerCleared);
CHECK(!GlobalHandles::IsNearDeath(h1.location()));
global_handles->Destroy(h1.location());
GlobalHandles::Destroy(h1.location());
}
@ -507,9 +512,10 @@ TEST(DeleteWeakGlobalHandle) {
h = global_handles->Create(*i);
}
global_handles->MakeWeak(h.location(),
reinterpret_cast<void*>(1234),
&TestWeakGlobalHandleCallback);
std::pair<Handle<Object>*, int> handle_and_id(&h, 1234);
GlobalHandles::MakeWeak(h.location(),
reinterpret_cast<void*>(&handle_and_id),
&TestWeakGlobalHandleCallback);
// Scanvenge does not recognize weak reference.
heap->PerformScavenge();

View File

@ -35,6 +35,7 @@
#include <errno.h>
#endif
#include <utility>
#include "v8.h"
@ -245,12 +246,14 @@ TEST(MapCompact) {
static int NumberOfWeakCalls = 0;
static void WeakPointerCallback(v8::Isolate* isolate,
v8::Persistent<v8::Value>* handle,
void* id) {
ASSERT(id == reinterpret_cast<void*>(1234));
static void WeakPointerCallback(
const v8::WeakCallbackData<v8::Value, void>& data) {
std::pair<v8::Persistent<v8::Value>*, int>* p =
reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>(
data.GetParameter());
ASSERT_EQ(1234, p->second);
NumberOfWeakCalls++;
handle->Reset();
p->first->Reset();
}
@ -268,15 +271,18 @@ TEST(ObjectGroups) {
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
Handle<Object> g1c1 =
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
global_handles->MakeWeak(g1s1.location(),
reinterpret_cast<void*>(1234),
&WeakPointerCallback);
global_handles->MakeWeak(g1s2.location(),
reinterpret_cast<void*>(1234),
&WeakPointerCallback);
global_handles->MakeWeak(g1c1.location(),
reinterpret_cast<void*>(1234),
&WeakPointerCallback);
std::pair<Handle<Object>*, int> g1s1_and_id(&g1s1, 1234);
GlobalHandles::MakeWeak(g1s1.location(),
reinterpret_cast<void*>(&g1s1_and_id),
&WeakPointerCallback);
std::pair<Handle<Object>*, int> g1s2_and_id(&g1s2, 1234);
GlobalHandles::MakeWeak(g1s2.location(),
reinterpret_cast<void*>(&g1s2_and_id),
&WeakPointerCallback);
std::pair<Handle<Object>*, int> g1c1_and_id(&g1c1, 1234);
GlobalHandles::MakeWeak(g1c1.location(),
reinterpret_cast<void*>(&g1c1_and_id),
&WeakPointerCallback);
Handle<Object> g2s1 =
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
@ -284,15 +290,18 @@ TEST(ObjectGroups) {
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
Handle<Object> g2c1 =
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
global_handles->MakeWeak(g2s1.location(),
reinterpret_cast<void*>(1234),
&WeakPointerCallback);
global_handles->MakeWeak(g2s2.location(),
reinterpret_cast<void*>(1234),
&WeakPointerCallback);
global_handles->MakeWeak(g2c1.location(),
reinterpret_cast<void*>(1234),
&WeakPointerCallback);
std::pair<Handle<Object>*, int> g2s1_and_id(&g2s1, 1234);
GlobalHandles::MakeWeak(g2s1.location(),
reinterpret_cast<void*>(&g2s1_and_id),
&WeakPointerCallback);
std::pair<Handle<Object>*, int> g2s2_and_id(&g2s2, 1234);
GlobalHandles::MakeWeak(g2s2.location(),
reinterpret_cast<void*>(&g2s2_and_id),
&WeakPointerCallback);
std::pair<Handle<Object>*, int> g2c1_and_id(&g2c1, 1234);
GlobalHandles::MakeWeak(g2c1.location(),
reinterpret_cast<void*>(&g2c1_and_id),
&WeakPointerCallback);
Handle<Object> root = global_handles->Create(*g1s1); // make a root.
@ -319,9 +328,10 @@ TEST(ObjectGroups) {
CHECK_EQ(0, NumberOfWeakCalls);
// Weaken the root.
global_handles->MakeWeak(root.location(),
reinterpret_cast<void*>(1234),
&WeakPointerCallback);
std::pair<Handle<Object>*, int> root_and_id(&root, 1234);
GlobalHandles::MakeWeak(root.location(),
reinterpret_cast<void*>(&root_and_id),
&WeakPointerCallback);
// But make children strong roots---all the objects (except for children)
// should be collectable now.
global_handles->ClearWeakness(g1c1.location());
@ -347,12 +357,12 @@ TEST(ObjectGroups) {
CHECK_EQ(5, NumberOfWeakCalls);
// And now make children weak again and collect them.
global_handles->MakeWeak(g1c1.location(),
reinterpret_cast<void*>(1234),
&WeakPointerCallback);
global_handles->MakeWeak(g2c1.location(),
reinterpret_cast<void*>(1234),
&WeakPointerCallback);
GlobalHandles::MakeWeak(g1c1.location(),
reinterpret_cast<void*>(&g1c1_and_id),
&WeakPointerCallback);
GlobalHandles::MakeWeak(g2c1.location(),
reinterpret_cast<void*>(&g2c1_and_id),
&WeakPointerCallback);
heap->CollectGarbage(OLD_POINTER_SPACE);
CHECK_EQ(7, NumberOfWeakCalls);

View File

@ -25,6 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <utility>
#include "v8.h"
#include "global-handles.h"
@ -64,12 +66,14 @@ static void PutIntoWeakMap(Handle<JSWeakMap> weakmap,
}
static int NumberOfWeakCalls = 0;
static void WeakPointerCallback(v8::Isolate* isolate,
v8::Persistent<v8::Value>* handle,
void* id) {
ASSERT(id == reinterpret_cast<void*>(1234));
static void WeakPointerCallback(
const v8::WeakCallbackData<v8::Value, void>& data) {
std::pair<v8::Persistent<v8::Value>*, int>* p =
reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>(
data.GetParameter());
ASSERT_EQ(1234, p->second);
NumberOfWeakCalls++;
handle->Reset();
p->first->Reset();
}
@ -112,9 +116,10 @@ TEST(Weakness) {
// Make the global reference to the key weak.
{
HandleScope scope(isolate);
global_handles->MakeWeak(key.location(),
reinterpret_cast<void*>(1234),
&WeakPointerCallback);
std::pair<Handle<Object>*, int> handle_and_id(&key, 1234);
GlobalHandles::MakeWeak(key.location(),
reinterpret_cast<void*>(&handle_and_id),
&WeakPointerCallback);
}
CHECK(global_handles->IsWeak(key.location()));

View File

@ -25,6 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <utility>
#include "v8.h"
#include "global-handles.h"
@ -64,12 +66,14 @@ static void PutIntoWeakSet(Handle<JSWeakSet> weakset,
}
static int NumberOfWeakCalls = 0;
static void WeakPointerCallback(v8::Isolate* isolate,
v8::Persistent<v8::Value>* handle,
void* id) {
ASSERT(id == reinterpret_cast<void*>(1234));
static void WeakPointerCallback(
const v8::WeakCallbackData<v8::Value, void>& data) {
std::pair<v8::Persistent<v8::Value>*, int>* p =
reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>(
data.GetParameter());
ASSERT_EQ(1234, p->second);
NumberOfWeakCalls++;
handle->Reset();
p->first->Reset();
}
@ -112,9 +116,10 @@ TEST(WeakSet_Weakness) {
// Make the global reference to the key weak.
{
HandleScope scope(isolate);
global_handles->MakeWeak(key.location(),
reinterpret_cast<void*>(1234),
&WeakPointerCallback);
std::pair<Handle<Object>*, int> handle_and_id(&key, 1234);
GlobalHandles::MakeWeak(key.location(),
reinterpret_cast<void*>(&handle_and_id),
&WeakPointerCallback);
}
CHECK(global_handles->IsWeak(key.location()));