Version 3.24.4
Removed all stuff marked as V8_DEPRECATED.
Performance and stability improvements on all platforms.
git-svn-id: http://v8.googlecode.com/svn/trunk@18354 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/ChangeLog b/ChangeLog
index fb0817d..0bbe65d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-12-18: Version 3.24.4
+
+ Removed all stuff marked as V8_DEPRECATED.
+
+ Performance and stability improvements on all platforms.
+
+
2013-12-17: Version 3.24.3
Performance and stability improvements on all platforms.
diff --git a/DEPS b/DEPS
index b91ae4e..b1d3c3d 100644
--- a/DEPS
+++ b/DEPS
@@ -8,7 +8,7 @@
"http://gyp.googlecode.com/svn/trunk@1685",
"v8/third_party/icu":
- "https://src.chromium.org/chrome/trunk/deps/third_party/icu46@214189",
+ "https://src.chromium.org/chrome/trunk/deps/third_party/icu46@239289",
}
deps_os = {
diff --git a/Makefile b/Makefile
index b5882c6..50d9124 100644
--- a/Makefile
+++ b/Makefile
@@ -444,4 +444,4 @@
--revision 1685
svn checkout --force \
https://src.chromium.org/chrome/trunk/deps/third_party/icu46 \
- third_party/icu --revision 214189
+ third_party/icu --revision 239289
diff --git a/include/v8-profiler.h b/include/v8-profiler.h
index 8d5e4ba..e88f472 100644
--- a/include/v8-profiler.h
+++ b/include/v8-profiler.h
@@ -96,9 +96,6 @@
*/
class V8_EXPORT CpuProfile {
public:
- /** Returns CPU profile UID (assigned by the profiler.) */
- unsigned GetUid() const;
-
/** Returns CPU profile title. */
Handle<String> GetTitle() const;
@@ -151,15 +148,6 @@
void SetSamplingInterval(int us);
/**
- * Returns the number of profiles collected (doesn't include
- * profiles that are being collected at the moment of call.)
- */
- int GetProfileCount();
-
- /** Returns a profile by index. */
- const CpuProfile* GetCpuProfile(int index);
-
- /**
* Starts collecting CPU profile. Title may be an empty string. It
* is allowed to have several profiles being collected at
* once. Attempts to start collecting several profiles with the same
@@ -179,13 +167,6 @@
const CpuProfile* StopCpuProfiling(Handle<String> title);
/**
- * Deletes all existing profiles, also cancelling all profiling
- * activity. All previously returned pointers to profiles and their
- * contents become invalid after this call.
- */
- void DeleteAllCpuProfiles();
-
- /**
* Tells the profiler whether the embedder is idle.
*/
void SetIdle(bool is_idle);
@@ -389,6 +370,19 @@
SnapshotObjectId GetObjectId(Handle<Value> value);
/**
+ * Returns heap object with given SnapshotObjectId if the object is alive,
+ * otherwise empty handle is returned.
+ */
+ Handle<Value> FindObjectById(SnapshotObjectId id);
+
+ /**
+ * Clears internal map from SnapshotObjectId to heap object. The new objects
+ * will not be added into it unless a heap snapshot is taken or heap object
+ * tracking is kicked off.
+ */
+ void ClearObjectIds();
+
+ /**
* A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return
* it in case heap profiler cannot find id for the object passed as
* parameter. HeapSnapshot::GetNodeById will always return NULL for such id.
@@ -475,21 +469,6 @@
*/
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();
diff --git a/include/v8.h b/include/v8.h
index 9bf9608..99827fe 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -455,18 +455,6 @@
};
-// 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 @@
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 @@
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 @@
~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 @@
}
};
- 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;
@@ -1145,11 +1101,6 @@
Local<Value> Run();
/**
- * Returns the script id value.
- */
- V8_DEPRECATED("Use GetId instead", Local<Value> Id());
-
- /**
* Returns the script id.
*/
int GetId();
@@ -1240,8 +1191,6 @@
// 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 @@
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 @@
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 @@
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 @@
*/
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 @@
*/
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 @@
*/
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
@@ -1983,30 +1887,6 @@
};
/**
- * 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()
* method of the object) then the length() method returns 0 and the * operator
@@ -2487,7 +2367,6 @@
* 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:
@@ -2656,11 +2535,6 @@
bool IsBuiltin() const;
/**
- * Returns scriptId object.
- */
- V8_DEPRECATED("Use ScriptId instead", Handle<Value> GetScriptId() const);
-
- /**
* Returns scriptId.
*/
int ScriptId() const;
@@ -2751,8 +2625,6 @@
* 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 @@
*/
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 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 @@
* 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 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 @@
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 @@
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 @@
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 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 @@
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 @@
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 @@
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 @@
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<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 @@
*/
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 (*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 @@
*/
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 @@
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 @@
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 @@
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 @@
/** 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 @@
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 @@
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 @@
}
-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 @@
}
-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(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::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 @@
}
-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);
diff --git a/samples/lineprocessor.cc b/samples/lineprocessor.cc
index 925e148..4823a48 100644
--- a/samples/lineprocessor.cc
+++ b/samples/lineprocessor.cc
@@ -204,12 +204,12 @@
// Bind the global 'print' function to the C++ Print callback.
global->Set(v8::String::NewFromUtf8(isolate, "print"),
- v8::FunctionTemplate::New(Print));
+ v8::FunctionTemplate::New(isolate, Print));
if (cycle_type == CycleInJs) {
// Bind the global 'read_line' function to the C++ Print callback.
global->Set(v8::String::NewFromUtf8(isolate, "read_line"),
- v8::FunctionTemplate::New(ReadLine));
+ v8::FunctionTemplate::New(isolate, ReadLine));
}
// Create a new execution environment containing the built-in
diff --git a/samples/process.cc b/samples/process.cc
index 7e3f78f..48ad33f 100644
--- a/samples/process.cc
+++ b/samples/process.cc
@@ -162,7 +162,7 @@
// built-in global functions.
Handle<ObjectTemplate> global = ObjectTemplate::New();
global->Set(String::NewFromUtf8(GetIsolate(), "log"),
- FunctionTemplate::New(LogCallback));
+ FunctionTemplate::New(GetIsolate(), LogCallback));
// Each processor gets its own context so different processors don't
// affect each other. Context::New returns a persistent handle which
diff --git a/samples/shell.cc b/samples/shell.cc
index f651850..e98eb75 100644
--- a/samples/shell.cc
+++ b/samples/shell.cc
@@ -101,19 +101,19 @@
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
// Bind the global 'print' function to the C++ Print callback.
global->Set(v8::String::NewFromUtf8(isolate, "print"),
- v8::FunctionTemplate::New(Print));
+ v8::FunctionTemplate::New(isolate, Print));
// Bind the global 'read' function to the C++ Read callback.
global->Set(v8::String::NewFromUtf8(isolate, "read"),
- v8::FunctionTemplate::New(Read));
+ v8::FunctionTemplate::New(isolate, Read));
// Bind the global 'load' function to the C++ Load callback.
global->Set(v8::String::NewFromUtf8(isolate, "load"),
- v8::FunctionTemplate::New(Load));
+ v8::FunctionTemplate::New(isolate, Load));
// Bind the 'quit' function
global->Set(v8::String::NewFromUtf8(isolate, "quit"),
- v8::FunctionTemplate::New(Quit));
+ v8::FunctionTemplate::New(isolate, Quit));
// Bind the 'version' function
global->Set(v8::String::NewFromUtf8(isolate, "version"),
- v8::FunctionTemplate::New(Version));
+ v8::FunctionTemplate::New(isolate, Version));
return v8::Context::New(isolate, NULL, global);
}
diff --git a/src/allocation-tracker.cc b/src/allocation-tracker.cc
index 8044cef..59ba6c9 100644
--- a/src/allocation-tracker.cc
+++ b/src/allocation-tracker.cc
@@ -246,16 +246,15 @@
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::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();
}
diff --git a/src/allocation-tracker.h b/src/allocation-tracker.h
index 6844716..1a5dc9e 100644
--- a/src/allocation-tracker.h
+++ b/src/allocation-tracker.h
@@ -112,9 +112,9 @@
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_;
diff --git a/src/api.cc b/src/api.cc
index 02b6be4..9a68f63 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -472,11 +472,6 @@
}
-v8::Handle<Value> ThrowException(v8::Handle<v8::Value> value) {
- return v8::Isolate::GetCurrent()->ThrowException(value);
-}
-
-
RegisteredExtension* RegisteredExtension::first_extension_ = NULL;
@@ -523,42 +518,6 @@
}
-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) {
- 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 @@
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 @@
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 @@
}
-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(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 @@
}
-// 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,
@@ -1465,13 +1368,15 @@
// Ensure that the object template has a constructor. If no
// constructor is available we create one.
static i::Handle<i::FunctionTemplateInfo> EnsureConstructor(
+ i::Isolate* isolate,
ObjectTemplate* object_template) {
i::Object* obj = Utils::OpenHandle(object_template)->constructor();
if (!obj ->IsUndefined()) {
i::FunctionTemplateInfo* info = i::FunctionTemplateInfo::cast(obj);
- return i::Handle<i::FunctionTemplateInfo>(info, info->GetIsolate());
+ return i::Handle<i::FunctionTemplateInfo>(info, isolate);
}
- Local<FunctionTemplate> templ = FunctionTemplate::New();
+ Local<FunctionTemplate> templ =
+ FunctionTemplate::New(reinterpret_cast<Isolate*>(isolate));
i::Handle<i::FunctionTemplateInfo> constructor = Utils::OpenHandle(*templ);
constructor->set_instance_template(*Utils::OpenHandle(object_template));
Utils::OpenHandle(object_template)->set_constructor(*constructor);
@@ -1493,6 +1398,7 @@
static inline i::Handle<i::TemplateInfo> GetTemplateInfo(
+ i::Isolate* isolate,
Template* template_obj) {
return Utils::OpenHandle(template_obj);
}
@@ -1500,8 +1406,9 @@
// TODO(dcarney): remove this with ObjectTemplate::SetAccessor
static inline i::Handle<i::TemplateInfo> GetTemplateInfo(
+ i::Isolate* isolate,
ObjectTemplate* object_template) {
- EnsureConstructor(object_template);
+ EnsureConstructor(isolate, object_template);
return Utils::OpenHandle(object_template);
}
@@ -1522,7 +1429,7 @@
i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(
name, getter, setter, data, settings, attribute, signature);
if (obj.is_null()) return false;
- i::Handle<i::TemplateInfo> info = GetTemplateInfo(template_obj);
+ i::Handle<i::TemplateInfo> info = GetTemplateInfo(isolate, template_obj);
AddPropertyToTemplate(info, obj);
return true;
}
@@ -1574,7 +1481,7 @@
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ENTER_V8(isolate);
i::HandleScope scope(isolate);
- EnsureConstructor(this);
+ EnsureConstructor(isolate, this);
i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast(
Utils::OpenHandle(this)->constructor());
i::Handle<i::FunctionTemplateInfo> cons(constructor);
@@ -1601,7 +1508,7 @@
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ENTER_V8(isolate);
i::HandleScope scope(isolate);
- EnsureConstructor(this);
+ EnsureConstructor(isolate, this);
i::FunctionTemplateInfo* constructor =
i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
i::Handle<i::FunctionTemplateInfo> cons(constructor);
@@ -1617,7 +1524,7 @@
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ENTER_V8(isolate);
i::HandleScope scope(isolate);
- EnsureConstructor(this);
+ EnsureConstructor(isolate, this);
i::Handle<i::Struct> struct_info =
isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE);
@@ -1650,7 +1557,7 @@
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ENTER_V8(isolate);
i::HandleScope scope(isolate);
- EnsureConstructor(this);
+ EnsureConstructor(isolate, this);
i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast(
Utils::OpenHandle(this)->constructor());
i::Handle<i::FunctionTemplateInfo> cons(constructor);
@@ -1678,7 +1585,7 @@
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ENTER_V8(isolate);
i::HandleScope scope(isolate);
- EnsureConstructor(this);
+ EnsureConstructor(isolate, this);
i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast(
Utils::OpenHandle(this)->constructor());
i::Handle<i::FunctionTemplateInfo> cons(constructor);
@@ -1712,7 +1619,7 @@
// The internal field count is set by the constructor function's
// construct code, so we ensure that there is a constructor
// function to do the setting.
- EnsureConstructor(this);
+ EnsureConstructor(isolate, this);
}
Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value));
}
@@ -1920,25 +1827,6 @@
}
-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 +2209,6 @@
}
-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 +2248,6 @@
}
-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 +4163,6 @@
}
-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;
@@ -5278,11 +5144,11 @@
if (!global_template.IsEmpty()) {
// Make sure that the global_template has a constructor.
- global_constructor = EnsureConstructor(*global_template);
+ global_constructor = EnsureConstructor(isolate, *global_template);
// Create a fresh template for the global proxy object.
proxy_template = ObjectTemplate::New();
- proxy_constructor = EnsureConstructor(*proxy_template);
+ proxy_constructor = EnsureConstructor(isolate, *proxy_template);
// Set the global template to be the prototype template of
// global proxy template.
@@ -5373,38 +5239,12 @@
}
-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 +5339,6 @@
}
-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 +5530,6 @@
}
-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 +5581,6 @@
}
-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 +5663,6 @@
}
-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 +5754,6 @@
}
-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 +5799,6 @@
}
-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 +5864,6 @@
}
-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 +5959,6 @@
}
-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 +5972,6 @@
}
-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 +6304,6 @@
}
-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 +6576,6 @@
}
-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();
@@ -7205,11 +6967,6 @@
}
-unsigned CpuProfile::GetUid() const {
- return reinterpret_cast<const i::CpuProfile*>(this)->uid();
-}
-
-
Handle<String> CpuProfile::GetTitle() const {
i::Isolate* isolate = i::Isolate::Current();
const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
@@ -7247,11 +7004,6 @@
}
-int CpuProfiler::GetProfileCount() {
- return reinterpret_cast<i::CpuProfiler*>(this)->GetProfilesCount();
-}
-
-
void CpuProfiler::SetSamplingInterval(int us) {
ASSERT(us >= 0);
return reinterpret_cast<i::CpuProfiler*>(this)->set_sampling_interval(
@@ -7259,12 +7011,6 @@
}
-const CpuProfile* CpuProfiler::GetCpuProfile(int index) {
- return reinterpret_cast<const CpuProfile*>(
- reinterpret_cast<i::CpuProfiler*>(this)->GetProfile(index));
-}
-
-
void CpuProfiler::StartCpuProfiling(Handle<String> title, bool record_samples) {
reinterpret_cast<i::CpuProfiler*>(this)->StartProfiling(
*Utils::OpenHandle(*title), record_samples);
@@ -7278,11 +7024,6 @@
}
-void CpuProfiler::DeleteAllCpuProfiles() {
- reinterpret_cast<i::CpuProfiler*>(this)->DeleteAllProfiles();
-}
-
-
void CpuProfiler::SetIdle(bool is_idle) {
i::Isolate* isolate = reinterpret_cast<i::CpuProfiler*>(this)->isolate();
i::StateTag state = isolate->current_vm_state();
@@ -7477,6 +7218,19 @@
}
+Handle<Value> HeapProfiler::FindObjectById(SnapshotObjectId id) {
+ i::Handle<i::Object> obj =
+ reinterpret_cast<i::HeapProfiler*>(this)->FindHeapObjectById(id);
+ if (obj.is_null()) return Local<Value>();
+ return Utils::ToLocal(obj);
+}
+
+
+void HeapProfiler::ClearObjectIds() {
+ reinterpret_cast<i::HeapProfiler*>(this)->ClearHeapObjectMap();
+}
+
+
const HeapSnapshot* HeapProfiler::TakeHeapSnapshot(
Handle<String> title,
ActivityControl* control,
@@ -7527,16 +7281,6 @@
}
-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;
diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc
index 4eb08a1..5c149de 100644
--- a/src/arm/code-stubs-arm.cc
+++ b/src/arm/code-stubs-arm.cc
@@ -1231,216 +1231,6 @@
}
-void TranscendentalCacheStub::Generate(MacroAssembler* masm) {
- // Untagged case: double input in d2, double result goes
- // into d2.
- // Tagged case: tagged input on top of stack and in r0,
- // tagged result (heap number) goes into r0.
-
- Label input_not_smi;
- Label loaded;
- Label calculate;
- Label invalid_cache;
- const Register scratch0 = r9;
- Register scratch1 = no_reg; // will be r4
- const Register cache_entry = r0;
- const bool tagged = (argument_type_ == TAGGED);
-
- if (tagged) {
- // Argument is a number and is on stack and in r0.
- // Load argument and check if it is a smi.
- __ JumpIfNotSmi(r0, &input_not_smi);
-
- // Input is a smi. Convert to double and load the low and high words
- // of the double into r2, r3.
- __ SmiToDouble(d7, r0);
- __ vmov(r2, r3, d7);
- __ b(&loaded);
-
- __ bind(&input_not_smi);
- // Check if input is a HeapNumber.
- __ CheckMap(r0,
- r1,
- Heap::kHeapNumberMapRootIndex,
- &calculate,
- DONT_DO_SMI_CHECK);
- // Input is a HeapNumber. Load it to a double register and store the
- // low and high words into r2, r3.
- __ vldr(d0, FieldMemOperand(r0, HeapNumber::kValueOffset));
- __ vmov(r2, r3, d0);
- } else {
- // Input is untagged double in d2. Output goes to d2.
- __ vmov(r2, r3, d2);
- }
- __ bind(&loaded);
- // r2 = low 32 bits of double value
- // r3 = high 32 bits of double value
- // Compute hash (the shifts are arithmetic):
- // h = (low ^ high); h ^= h >> 16; h ^= h >> 8; h = h & (cacheSize - 1);
- __ eor(r1, r2, Operand(r3));
- __ eor(r1, r1, Operand(r1, ASR, 16));
- __ eor(r1, r1, Operand(r1, ASR, 8));
- ASSERT(IsPowerOf2(TranscendentalCache::SubCache::kCacheSize));
- __ And(r1, r1, Operand(TranscendentalCache::SubCache::kCacheSize - 1));
-
- // r2 = low 32 bits of double value.
- // r3 = high 32 bits of double value.
- // r1 = TranscendentalCache::hash(double value).
- Isolate* isolate = masm->isolate();
- ExternalReference cache_array =
- ExternalReference::transcendental_cache_array_address(isolate);
- __ mov(cache_entry, Operand(cache_array));
- // cache_entry points to cache array.
- int cache_array_index
- = type_ * sizeof(isolate->transcendental_cache()->caches_[0]);
- __ ldr(cache_entry, MemOperand(cache_entry, cache_array_index));
- // r0 points to the cache for the type type_.
- // If NULL, the cache hasn't been initialized yet, so go through runtime.
- __ cmp(cache_entry, Operand::Zero());
- __ b(eq, &invalid_cache);
-
-#ifdef DEBUG
- // Check that the layout of cache elements match expectations.
- { TranscendentalCache::SubCache::Element test_elem[2];
- char* elem_start = reinterpret_cast<char*>(&test_elem[0]);
- char* elem2_start = reinterpret_cast<char*>(&test_elem[1]);
- char* elem_in0 = reinterpret_cast<char*>(&(test_elem[0].in[0]));
- char* elem_in1 = reinterpret_cast<char*>(&(test_elem[0].in[1]));
- char* elem_out = reinterpret_cast<char*>(&(test_elem[0].output));
- CHECK_EQ(12, elem2_start - elem_start); // Two uint_32's and a pointer.
- CHECK_EQ(0, elem_in0 - elem_start);
- CHECK_EQ(kIntSize, elem_in1 - elem_start);
- CHECK_EQ(2 * kIntSize, elem_out - elem_start);
- }
-#endif
-
- // Find the address of the r1'st entry in the cache, i.e., &r0[r1*12].
- __ add(r1, r1, Operand(r1, LSL, 1));
- __ add(cache_entry, cache_entry, Operand(r1, LSL, 2));
- // Check if cache matches: Double value is stored in uint32_t[2] array.
- __ ldm(ia, cache_entry, r4.bit() | r5.bit() | r6.bit());
- __ cmp(r2, r4);
- __ cmp(r3, r5, eq);
- __ b(ne, &calculate);
-
- scratch1 = r4; // Start of scratch1 range.
-
- // Cache hit. Load result, cleanup and return.
- Counters* counters = masm->isolate()->counters();
- __ IncrementCounter(
- counters->transcendental_cache_hit(), 1, scratch0, scratch1);
- if (tagged) {
- // Pop input value from stack and load result into r0.
- __ pop();
- __ mov(r0, Operand(r6));
- } else {
- // Load result into d2.
- __ vldr(d2, FieldMemOperand(r6, HeapNumber::kValueOffset));
- }
- __ Ret();
-
- __ bind(&calculate);
- __ IncrementCounter(
- counters->transcendental_cache_miss(), 1, scratch0, scratch1);
- if (tagged) {
- __ bind(&invalid_cache);
- ExternalReference runtime_function =
- ExternalReference(RuntimeFunction(), masm->isolate());
- __ TailCallExternalReference(runtime_function, 1, 1);
- } else {
- Label no_update;
- Label skip_cache;
-
- // Call C function to calculate the result and update the cache.
- // r0: precalculated cache entry address.
- // r2 and r3: parts of the double value.
- // Store r0, r2 and r3 on stack for later before calling C function.
- __ Push(r3, r2, cache_entry);
- GenerateCallCFunction(masm, scratch0);
- __ GetCFunctionDoubleResult(d2);
-
- // Try to update the cache. If we cannot allocate a
- // heap number, we return the result without updating.
- __ Pop(r3, r2, cache_entry);
- __ LoadRoot(r5, Heap::kHeapNumberMapRootIndex);
- __ AllocateHeapNumber(r6, scratch0, scratch1, r5, &no_update);
- __ vstr(d2, FieldMemOperand(r6, HeapNumber::kValueOffset));
- __ stm(ia, cache_entry, r2.bit() | r3.bit() | r6.bit());
- __ Ret();
-
- __ bind(&invalid_cache);
- // The cache is invalid. Call runtime which will recreate the
- // cache.
- __ LoadRoot(r5, Heap::kHeapNumberMapRootIndex);
- __ AllocateHeapNumber(r0, scratch0, scratch1, r5, &skip_cache);
- __ vstr(d2, FieldMemOperand(r0, HeapNumber::kValueOffset));
- {
- FrameScope scope(masm, StackFrame::INTERNAL);
- __ push(r0);
- __ CallRuntime(RuntimeFunction(), 1);
- }
- __ vldr(d2, FieldMemOperand(r0, HeapNumber::kValueOffset));
- __ Ret();
-
- __ bind(&skip_cache);
- // Call C function to calculate the result and answer directly
- // without updating the cache.
- GenerateCallCFunction(masm, scratch0);
- __ GetCFunctionDoubleResult(d2);
- __ bind(&no_update);
-
- // We return the value in d2 without adding it to the cache, but
- // we cause a scavenging GC so that future allocations will succeed.
- {
- FrameScope scope(masm, StackFrame::INTERNAL);
-
- // Allocate an aligned object larger than a HeapNumber.
- ASSERT(4 * kPointerSize >= HeapNumber::kSize);
- __ mov(scratch0, Operand(4 * kPointerSize));
- __ push(scratch0);
- __ CallRuntimeSaveDoubles(Runtime::kAllocateInNewSpace);
- }
- __ Ret();
- }
-}
-
-
-void TranscendentalCacheStub::GenerateCallCFunction(MacroAssembler* masm,
- Register scratch) {
- Isolate* isolate = masm->isolate();
-
- __ push(lr);
- __ PrepareCallCFunction(0, 1, scratch);
- if (masm->use_eabi_hardfloat()) {
- __ vmov(d0, d2);
- } else {
- __ vmov(r0, r1, d2);
- }
- AllowExternalCallThatCantCauseGC scope(masm);
- switch (type_) {
- case TranscendentalCache::LOG:
- __ CallCFunction(ExternalReference::math_log_double_function(isolate),
- 0, 1);
- break;
- default:
- UNIMPLEMENTED();
- break;
- }
- __ pop(lr);
-}
-
-
-Runtime::FunctionId TranscendentalCacheStub::RuntimeFunction() {
- switch (type_) {
- // Add more cases when necessary.
- case TranscendentalCache::LOG: return Runtime::kMath_log;
- default:
- UNIMPLEMENTED();
- return Runtime::kAbort;
- }
-}
-
-
void MathPowStub::Generate(MacroAssembler* masm) {
const Register base = r1;
const Register exponent = r2;
diff --git a/src/arm/code-stubs-arm.h b/src/arm/code-stubs-arm.h
index e400686..6156384 100644
--- a/src/arm/code-stubs-arm.h
+++ b/src/arm/code-stubs-arm.h
@@ -37,30 +37,6 @@
void ArrayNativeCode(MacroAssembler* masm, Label* call_generic_code);
-// Compute a transcendental math function natively, or call the
-// TranscendentalCache runtime function.
-class TranscendentalCacheStub: public PlatformCodeStub {
- public:
- enum ArgumentType {
- TAGGED = 0 << TranscendentalCache::kTranscendentalTypeBits,
- UNTAGGED = 1 << TranscendentalCache::kTranscendentalTypeBits
- };
-
- TranscendentalCacheStub(TranscendentalCache::Type type,
- ArgumentType argument_type)
- : type_(type), argument_type_(argument_type) { }
- void Generate(MacroAssembler* masm);
- private:
- TranscendentalCache::Type type_;
- ArgumentType argument_type_;
- void GenerateCallCFunction(MacroAssembler* masm, Register scratch);
-
- Major MajorKey() { return TranscendentalCache; }
- int MinorKey() { return type_ | argument_type_; }
- Runtime::FunctionId RuntimeFunction();
-};
-
-
class StoreBufferOverflowStub: public PlatformCodeStub {
public:
explicit StoreBufferOverflowStub(SaveFPRegsMode save_fp)
diff --git a/src/arm/codegen-arm.cc b/src/arm/codegen-arm.cc
index 255e1f3..3ac30c5 100644
--- a/src/arm/codegen-arm.cc
+++ b/src/arm/codegen-arm.cc
@@ -37,15 +37,6 @@
namespace internal {
-UnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type) {
- switch (type) {
- case TranscendentalCache::LOG: return &log;
- default: UNIMPLEMENTED();
- }
- return NULL;
-}
-
-
#define __ masm.
diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc
index f6d3ea3..dbcce96 100644
--- a/src/arm/full-codegen-arm.cc
+++ b/src/arm/full-codegen-arm.cc
@@ -1025,6 +1025,16 @@
CallIC(ic, RelocInfo::CODE_TARGET, clause->CompareId());
patch_site.EmitPatchInfo();
+ Label skip;
+ __ b(&skip);
+ PrepareForBailout(clause, TOS_REG);
+ __ LoadRoot(ip, Heap::kTrueValueRootIndex);
+ __ cmp(r0, ip);
+ __ b(ne, &next_test);
+ __ Drop(1);
+ __ jmp(clause->body_target());
+ __ bind(&skip);
+
__ cmp(r0, Operand::Zero());
__ b(ne, &next_test);
__ Drop(1); // Switch value is no longer needed.
@@ -3698,13 +3708,11 @@
void FullCodeGenerator::EmitMathLog(CallRuntime* expr) {
- // Load the argument on the stack and call the stub.
- TranscendentalCacheStub stub(TranscendentalCache::LOG,
- TranscendentalCacheStub::TAGGED);
+ // Load the argument on the stack and call the runtime function.
ZoneList<Expression*>* args = expr->arguments();
ASSERT(args->length() == 1);
VisitForStackValue(args->at(0));
- __ CallStub(&stub);
+ __ CallRuntime(Runtime::kMath_log, 1);
context()->Plug(r0);
}
diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc
index 5a1d55e..e2b29df 100644
--- a/src/arm/lithium-arm.cc
+++ b/src/arm/lithium-arm.cc
@@ -1224,9 +1224,10 @@
LInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) {
- LOperand* input = UseFixedDouble(instr->value(), d2);
- LMathLog* result = new(zone()) LMathLog(input);
- return MarkAsCall(DefineFixedDouble(result, d2), instr);
+ ASSERT(instr->representation().IsDouble());
+ ASSERT(instr->value()->representation().IsDouble());
+ LOperand* input = UseFixedDouble(instr->value(), d0);
+ return MarkAsCall(DefineFixedDouble(new(zone()) LMathLog(input), d0), instr);
}
diff --git a/src/arm/lithium-arm.h b/src/arm/lithium-arm.h
index 4bac4b1..5c32031 100644
--- a/src/arm/lithium-arm.h
+++ b/src/arm/lithium-arm.h
@@ -488,10 +488,6 @@
DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
DECLARE_HYDROGEN_ACCESSOR(CallStub)
-
- TranscendentalCache::Type transcendental_type() {
- return hydrogen()->transcendental_type();
- }
};
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc
index 8f1c9c0..ade6928 100644
--- a/src/arm/lithium-codegen-arm.cc
+++ b/src/arm/lithium-codegen-arm.cc
@@ -1085,13 +1085,6 @@
CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
break;
}
- case CodeStub::TranscendentalCache: {
- __ ldr(r0, MemOperand(sp, 0));
- TranscendentalCacheStub stub(instr->transcendental_type(),
- TranscendentalCacheStub::TAGGED);
- CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
- break;
- }
default:
UNREACHABLE();
}
@@ -2134,7 +2127,7 @@
__ PrepareCallCFunction(0, 2, scratch0());
__ SetCallCDoubleArguments(left, right);
__ CallCFunction(
- ExternalReference::double_fp_operation(Token::MOD, isolate()),
+ ExternalReference::mod_two_doubles_operation(isolate()),
0, 2);
// Move the result in the double result register.
__ GetCFunctionDoubleResult(result);
@@ -3941,13 +3934,11 @@
void LCodeGen::DoMathLog(LMathLog* instr) {
- ASSERT(ToDoubleRegister(instr->result()).is(d2));
- // Set the context register to a GC-safe fake value. Clobbering it is
- // OK because this instruction is marked as a call.
- __ mov(cp, Operand::Zero());
- TranscendentalCacheStub stub(TranscendentalCache::LOG,
- TranscendentalCacheStub::UNTAGGED);
- CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
+ __ PrepareCallCFunction(0, 1, scratch0());
+ __ SetCallCDoubleArguments(ToDoubleRegister(instr->value()));
+ __ CallCFunction(ExternalReference::math_log_double_function(isolate()),
+ 0, 1);
+ __ GetCFunctionDoubleResult(ToDoubleRegister(instr->result()));
}
diff --git a/src/assembler.cc b/src/assembler.cc
index b77e92d..4ac2fb4 100644
--- a/src/assembler.cc
+++ b/src/assembler.cc
@@ -1093,13 +1093,6 @@
}
-ExternalReference ExternalReference::transcendental_cache_array_address(
- Isolate* isolate) {
- return ExternalReference(
- isolate->transcendental_cache()->cache_array_address());
-}
-
-
ExternalReference ExternalReference::new_deoptimizer_function(
Isolate* isolate) {
return ExternalReference(
@@ -1395,40 +1388,11 @@
#endif // V8_INTERPRETED_REGEXP
-static double add_two_doubles(double x, double y) {
- return x + y;
-}
-
-
-static double sub_two_doubles(double x, double y) {
- return x - y;
-}
-
-
-static double mul_two_doubles(double x, double y) {
- return x * y;
-}
-
-
-static double div_two_doubles(double x, double y) {
- return x / y;
-}
-
-
-static double mod_two_doubles(double x, double y) {
- return modulo(x, y);
-}
-
-
-static double math_log_double(double x) {
- return log(x);
-}
-
-
ExternalReference ExternalReference::math_log_double_function(
Isolate* isolate) {
+ typedef double (*d2d)(double x);
return ExternalReference(Redirect(isolate,
- FUNCTION_ADDR(math_log_double),
+ FUNCTION_ADDR(static_cast<d2d>(log)),
BUILTIN_FP_CALL));
}
@@ -1533,12 +1497,6 @@
}
-static int native_compare_doubles(double y, double x) {
- if (x == y) return EQUAL;
- return x < y ? LESS : GREATER;
-}
-
-
bool EvalComparison(Token::Value op, double op1, double op2) {
ASSERT(Token::IsCompareOp(op));
switch (op) {
@@ -1556,42 +1514,14 @@
}
-ExternalReference ExternalReference::double_fp_operation(
- Token::Value operation, Isolate* isolate) {
- typedef double BinaryFPOperation(double x, double y);
- BinaryFPOperation* function = NULL;
- switch (operation) {
- case Token::ADD:
- function = &add_two_doubles;
- break;
- case Token::SUB:
- function = &sub_two_doubles;
- break;
- case Token::MUL:
- function = &mul_two_doubles;
- break;
- case Token::DIV:
- function = &div_two_doubles;
- break;
- case Token::MOD:
- function = &mod_two_doubles;
- break;
- default:
- UNREACHABLE();
- }
+ExternalReference ExternalReference::mod_two_doubles_operation(
+ Isolate* isolate) {
return ExternalReference(Redirect(isolate,
- FUNCTION_ADDR(function),
+ FUNCTION_ADDR(modulo),
BUILTIN_FP_FP_CALL));
}
-ExternalReference ExternalReference::compare_doubles(Isolate* isolate) {
- return ExternalReference(Redirect(isolate,
- FUNCTION_ADDR(native_compare_doubles),
- BUILTIN_COMPARE_CALL));
-}
-
-
#ifdef ENABLE_DEBUGGER_SUPPORT
ExternalReference ExternalReference::debug_break(Isolate* isolate) {
return ExternalReference(Redirect(isolate, FUNCTION_ADDR(Debug_Break)));
diff --git a/src/assembler.h b/src/assembler.h
index 6c06262..3ccfccf 100644
--- a/src/assembler.h
+++ b/src/assembler.h
@@ -718,7 +718,6 @@
Isolate* isolate);
static ExternalReference flush_icache_function(Isolate* isolate);
static ExternalReference perform_gc_function(Isolate* isolate);
- static ExternalReference transcendental_cache_array_address(Isolate* isolate);
static ExternalReference delete_handle_scope_extensions(Isolate* isolate);
static ExternalReference get_date_field_function(Isolate* isolate);
@@ -784,9 +783,7 @@
static ExternalReference new_space_high_promotion_mode_active_address(
Isolate* isolate);
- static ExternalReference double_fp_operation(Token::Value operation,
- Isolate* isolate);
- static ExternalReference compare_doubles(Isolate* isolate);
+ static ExternalReference mod_two_doubles_operation(Isolate* isolate);
static ExternalReference power_double_double_function(Isolate* isolate);
static ExternalReference power_double_int_function(Isolate* isolate);
diff --git a/src/ast.cc b/src/ast.cc
index 681b3d4..ecf83ea 100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -1121,7 +1121,7 @@
Expression* label,
ZoneList<Statement*>* statements,
int pos)
- : AstNode(pos),
+ : Expression(isolate, pos),
label_(label),
statements_(statements),
compare_type_(Type::None(), isolate),
diff --git a/src/ast.h b/src/ast.h
index 4e413c5..cf3ef92 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -115,17 +115,14 @@
V(CountOperation) \
V(BinaryOperation) \
V(CompareOperation) \
- V(ThisFunction)
-
-#define AUXILIARY_NODE_LIST(V) \
+ V(ThisFunction) \
V(CaseClause)
#define AST_NODE_LIST(V) \
DECLARATION_NODE_LIST(V) \
MODULE_NODE_LIST(V) \
STATEMENT_NODE_LIST(V) \
- EXPRESSION_NODE_LIST(V) \
- AUXILIARY_NODE_LIST(V)
+ EXPRESSION_NODE_LIST(V)
// Forward declarations
class AstConstructionVisitor;
@@ -1105,7 +1102,7 @@
};
-class CaseClause V8_FINAL : public AstNode {
+class CaseClause V8_FINAL : public Expression {
public:
DECLARE_NODE_TYPE(CaseClause)
@@ -1147,16 +1144,11 @@
void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) {
tag_ = tag;
cases_ = cases;
- switch_type_ = UNKNOWN_SWITCH;
}
Expression* tag() const { return tag_; }
ZoneList<CaseClause*>* cases() const { return cases_; }
- enum SwitchType { UNKNOWN_SWITCH, SMI_SWITCH, STRING_SWITCH, GENERIC_SWITCH };
- SwitchType switch_type() const { return switch_type_; }
- void set_switch_type(SwitchType switch_type) { switch_type_ = switch_type; }
-
protected:
SwitchStatement(Isolate* isolate, ZoneStringList* labels, int pos)
: BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS, pos),
@@ -1166,7 +1158,6 @@
private:
Expression* tag_;
ZoneList<CaseClause*>* cases_;
- SwitchType switch_type_;
};
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index ac3fbb0..0a9fdcb 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -1302,7 +1302,7 @@
native_context()->set_out_of_memory(heap->false_value());
// Initialize the embedder data slot.
- Handle<FixedArray> embedder_data = factory->NewFixedArray(2);
+ Handle<FixedArray> embedder_data = factory->NewFixedArray(3);
native_context()->set_embedder_data(*embedder_data);
}
diff --git a/src/code-stubs.h b/src/code-stubs.h
index bedf295..2ab62b0 100644
--- a/src/code-stubs.h
+++ b/src/code-stubs.h
@@ -56,7 +56,6 @@
V(RecordWrite) \
V(StoreBufferOverflow) \
V(RegExpExec) \
- V(TranscendentalCache) \
V(Instanceof) \
V(ConvertToDouble) \
V(WriteInt32ToHeapNumber) \
@@ -1177,10 +1176,6 @@
CompareIC::State* handler_state,
Token::Value* op);
- static CompareIC::State CompareState(int minor_key) {
- return static_cast<CompareIC::State>(HandlerStateField::decode(minor_key));
- }
-
virtual InlineCacheState GetICState();
private:
diff --git a/src/codegen.h b/src/codegen.h
index 33672a2..b271d21 100644
--- a/src/codegen.h
+++ b/src/codegen.h
@@ -89,7 +89,6 @@
// generated code both in runtime and compiled code.
typedef double (*UnaryMathFunction)(double x);
-UnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type);
UnaryMathFunction CreateExpFunction();
UnaryMathFunction CreateSqrtFunction();
diff --git a/src/compiler.cc b/src/compiler.cc
index c6dfa04..6b7786f 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -355,7 +355,6 @@
}
MODULE_NODE_LIST(DEF_VISIT)
DECLARATION_NODE_LIST(DEF_VISIT)
- AUXILIARY_NODE_LIST(DEF_VISIT)
#undef DEF_VISIT
};
diff --git a/src/cpu-profiler.cc b/src/cpu-profiler.cc
index ef39341..c36850c 100644
--- a/src/cpu-profiler.cc
+++ b/src/cpu-profiler.cc
@@ -380,7 +380,6 @@
sampling_interval_(TimeDelta::FromMicroseconds(
FLAG_cpu_profiler_sampling_interval)),
profiles_(new CpuProfilesCollection(isolate->heap())),
- next_profile_uid_(1),
generator_(NULL),
processor_(NULL),
is_profiling_(false) {
@@ -395,7 +394,6 @@
sampling_interval_(TimeDelta::FromMicroseconds(
FLAG_cpu_profiler_sampling_interval)),
profiles_(test_profiles),
- next_profile_uid_(1),
generator_(test_generator),
processor_(test_processor),
is_profiling_(false) {
@@ -421,7 +419,7 @@
void CpuProfiler::StartProfiling(const char* title, bool record_samples) {
- if (profiles_->StartProfiling(title, next_profile_uid_++, record_samples)) {
+ if (profiles_->StartProfiling(title, record_samples)) {
StartProcessorIfNotStarted();
}
processor_->AddCurrentStack(isolate_);
diff --git a/src/cpu-profiler.h b/src/cpu-profiler.h
index fcb9a67..53f00ff 100644
--- a/src/cpu-profiler.h
+++ b/src/cpu-profiler.h
@@ -268,7 +268,6 @@
Isolate* isolate_;
TimeDelta sampling_interval_;
CpuProfilesCollection* profiles_;
- unsigned next_profile_uid_;
ProfileGenerator* generator_;
ProfilerEventsProcessor* processor_;
bool saved_is_logging_;
diff --git a/src/d8-posix.cc b/src/d8-posix.cc
index 25f79a4..c0485c6 100644
--- a/src/d8-posix.cc
+++ b/src/d8-posix.cc
@@ -723,19 +723,19 @@
void Shell::AddOSMethods(Isolate* isolate, Handle<ObjectTemplate> os_templ) {
os_templ->Set(String::NewFromUtf8(isolate, "system"),
- FunctionTemplate::New(System));
+ FunctionTemplate::New(isolate, System));
os_templ->Set(String::NewFromUtf8(isolate, "chdir"),
- FunctionTemplate::New(ChangeDirectory));
+ FunctionTemplate::New(isolate, ChangeDirectory));
os_templ->Set(String::NewFromUtf8(isolate, "setenv"),
- FunctionTemplate::New(SetEnvironment));
+ FunctionTemplate::New(isolate, SetEnvironment));
os_templ->Set(String::NewFromUtf8(isolate, "unsetenv"),
- FunctionTemplate::New(UnsetEnvironment));
+ FunctionTemplate::New(isolate, UnsetEnvironment));
os_templ->Set(String::NewFromUtf8(isolate, "umask"),
- FunctionTemplate::New(SetUMask));
+ FunctionTemplate::New(isolate, SetUMask));
os_templ->Set(String::NewFromUtf8(isolate, "mkdirp"),
- FunctionTemplate::New(MakeDirectory));
+ FunctionTemplate::New(isolate, MakeDirectory));
os_templ->Set(String::NewFromUtf8(isolate, "rmdir"),
- FunctionTemplate::New(RemoveDirectory));
+ FunctionTemplate::New(isolate, RemoveDirectory));
}
} // namespace v8
diff --git a/src/d8.cc b/src/d8.cc
index eb70f3e..00eca19 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -860,38 +860,38 @@
Handle<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
Handle<ObjectTemplate> global_template = ObjectTemplate::New();
global_template->Set(String::NewFromUtf8(isolate, "print"),
- FunctionTemplate::New(Print));
+ FunctionTemplate::New(isolate, Print));
global_template->Set(String::NewFromUtf8(isolate, "write"),
- FunctionTemplate::New(Write));
+ FunctionTemplate::New(isolate, Write));
global_template->Set(String::NewFromUtf8(isolate, "read"),
- FunctionTemplate::New(Read));
+ FunctionTemplate::New(isolate, Read));
global_template->Set(String::NewFromUtf8(isolate, "readbuffer"),
- FunctionTemplate::New(ReadBuffer));
+ FunctionTemplate::New(isolate, ReadBuffer));
global_template->Set(String::NewFromUtf8(isolate, "readline"),
- FunctionTemplate::New(ReadLine));
+ FunctionTemplate::New(isolate, ReadLine));
global_template->Set(String::NewFromUtf8(isolate, "load"),
- FunctionTemplate::New(Load));
+ FunctionTemplate::New(isolate, Load));
global_template->Set(String::NewFromUtf8(isolate, "quit"),
- FunctionTemplate::New(Quit));
+ FunctionTemplate::New(isolate, Quit));
global_template->Set(String::NewFromUtf8(isolate, "version"),
- FunctionTemplate::New(Version));
+ FunctionTemplate::New(isolate, Version));
// Bind the Realm object.
Handle<ObjectTemplate> realm_template = ObjectTemplate::New();
realm_template->Set(String::NewFromUtf8(isolate, "current"),
- FunctionTemplate::New(RealmCurrent));
+ FunctionTemplate::New(isolate, RealmCurrent));
realm_template->Set(String::NewFromUtf8(isolate, "owner"),
- FunctionTemplate::New(RealmOwner));
+ FunctionTemplate::New(isolate, RealmOwner));
realm_template->Set(String::NewFromUtf8(isolate, "global"),
- FunctionTemplate::New(RealmGlobal));
+ FunctionTemplate::New(isolate, RealmGlobal));
realm_template->Set(String::NewFromUtf8(isolate, "create"),
- FunctionTemplate::New(RealmCreate));
+ FunctionTemplate::New(isolate, RealmCreate));
realm_template->Set(String::NewFromUtf8(isolate, "dispose"),
- FunctionTemplate::New(RealmDispose));
+ FunctionTemplate::New(isolate, RealmDispose));
realm_template->Set(String::NewFromUtf8(isolate, "switch"),
- FunctionTemplate::New(RealmSwitch));
+ FunctionTemplate::New(isolate, RealmSwitch));
realm_template->Set(String::NewFromUtf8(isolate, "eval"),
- FunctionTemplate::New(RealmEval));
+ FunctionTemplate::New(isolate, RealmEval));
realm_template->SetAccessor(String::NewFromUtf8(isolate, "shared"),
RealmSharedGet, RealmSharedSet);
global_template->Set(String::NewFromUtf8(isolate, "Realm"), realm_template);
@@ -899,7 +899,7 @@
#ifndef V8_SHARED
Handle<ObjectTemplate> performance_template = ObjectTemplate::New();
performance_template->Set(String::NewFromUtf8(isolate, "now"),
- FunctionTemplate::New(PerformanceNow));
+ FunctionTemplate::New(isolate, PerformanceNow));
global_template->Set(String::NewFromUtf8(isolate, "performance"),
performance_template);
#endif // V8_SHARED
diff --git a/src/debug.cc b/src/debug.cc
index 25be003..dbbfe7e 100644
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -646,11 +646,10 @@
// 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::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::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 @@
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 @@
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 @@
// 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>();
}
diff --git a/src/debug.h b/src/debug.h
index 8e71ea6..7eedfd2 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -201,9 +201,8 @@
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 @@
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
diff --git a/src/extensions/externalize-string-extension.cc b/src/extensions/externalize-string-extension.cc
index edc7dd8..7dc7a3c 100644
--- a/src/extensions/externalize-string-extension.cc
+++ b/src/extensions/externalize-string-extension.cc
@@ -64,10 +64,12 @@
ExternalizeStringExtension::GetNativeFunctionTemplate(
v8::Isolate* isolate, v8::Handle<v8::String> str) {
if (strcmp(*v8::String::Utf8Value(str), "externalizeString") == 0) {
- return v8::FunctionTemplate::New(ExternalizeStringExtension::Externalize);
+ return v8::FunctionTemplate::New(isolate,
+ ExternalizeStringExtension::Externalize);
} else {
ASSERT(strcmp(*v8::String::Utf8Value(str), "isAsciiString") == 0);
- return v8::FunctionTemplate::New(ExternalizeStringExtension::IsAscii);
+ return v8::FunctionTemplate::New(isolate,
+ ExternalizeStringExtension::IsAscii);
}
}
diff --git a/src/extensions/free-buffer-extension.cc b/src/extensions/free-buffer-extension.cc
index 5cf2b68..c2e3102 100644
--- a/src/extensions/free-buffer-extension.cc
+++ b/src/extensions/free-buffer-extension.cc
@@ -36,7 +36,7 @@
v8::Handle<v8::FunctionTemplate> FreeBufferExtension::GetNativeFunctionTemplate(
v8::Isolate* isolate,
v8::Handle<v8::String> str) {
- return v8::FunctionTemplate::New(FreeBufferExtension::FreeBuffer);
+ return v8::FunctionTemplate::New(isolate, FreeBufferExtension::FreeBuffer);
}
diff --git a/src/extensions/gc-extension.cc b/src/extensions/gc-extension.cc
index b8442c1..69fd717 100644
--- a/src/extensions/gc-extension.cc
+++ b/src/extensions/gc-extension.cc
@@ -35,7 +35,7 @@
v8::Handle<v8::FunctionTemplate> GCExtension::GetNativeFunctionTemplate(
v8::Isolate* isolate,
v8::Handle<v8::String> str) {
- return v8::FunctionTemplate::New(GCExtension::GC);
+ return v8::FunctionTemplate::New(isolate, GCExtension::GC);
}
diff --git a/src/extensions/statistics-extension.cc b/src/extensions/statistics-extension.cc
index 92d152d..767c9e7 100644
--- a/src/extensions/statistics-extension.cc
+++ b/src/extensions/statistics-extension.cc
@@ -38,7 +38,7 @@
v8::Isolate* isolate,
v8::Handle<v8::String> str) {
ASSERT(strcmp(*v8::String::Utf8Value(str), "getV8Statistics") == 0);
- return v8::FunctionTemplate::New(StatisticsExtension::GetCounters);
+ return v8::FunctionTemplate::New(isolate, StatisticsExtension::GetCounters);
}
diff --git a/src/extensions/trigger-failure-extension.cc b/src/extensions/trigger-failure-extension.cc
index 5fe6bbb..68dea93 100644
--- a/src/extensions/trigger-failure-extension.cc
+++ b/src/extensions/trigger-failure-extension.cc
@@ -44,13 +44,16 @@
v8::Handle<v8::String> str) {
if (strcmp(*v8::String::Utf8Value(str), "triggerCheckFalse") == 0) {
return v8::FunctionTemplate::New(
+ isolate,
TriggerFailureExtension::TriggerCheckFalse);
} else if (strcmp(*v8::String::Utf8Value(str), "triggerAssertFalse") == 0) {
return v8::FunctionTemplate::New(
+ isolate,
TriggerFailureExtension::TriggerAssertFalse);
} else {
CHECK_EQ(0, strcmp(*v8::String::Utf8Value(str), "triggerSlowAssertFalse"));
return v8::FunctionTemplate::New(
+ isolate,
TriggerFailureExtension::TriggerSlowAssertFalse);
}
}
diff --git a/src/global-handles.cc b/src/global-handles.cc
index 2ebe1c0..0944979 100644
--- a/src/global-handles.cc
+++ b/src/global-handles.cc
@@ -169,13 +169,6 @@
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 @@
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 @@
// 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 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::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);
}
diff --git a/src/global-handles.h b/src/global-handles.h
index 4b46aac..a406451 100644
--- a/src/global-handles.h
+++ b/src/global-handles.h
@@ -135,7 +135,6 @@
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 @@
// 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);
diff --git a/src/handles.cc b/src/handles.cc
index 2d41402..8bf3b0c 100644
--- a/src/handles.cc
+++ b/src/handles.cc
@@ -225,17 +225,15 @@
// 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 @@
// 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;
diff --git a/src/heap-inl.h b/src/heap-inl.h
index 3229aee..11783b3 100644
--- a/src/heap-inl.h
+++ b/src/heap-inl.h
@@ -747,56 +747,6 @@
}
-MaybeObject* TranscendentalCache::Get(Type type, double input) {
- SubCache* cache = caches_[type];
- if (cache == NULL) {
- caches_[type] = cache = new SubCache(isolate_, type);
- }
- return cache->Get(input);
-}
-
-
-Address TranscendentalCache::cache_array_address() {
- return reinterpret_cast<Address>(caches_);
-}
-
-
-double TranscendentalCache::SubCache::Calculate(double input) {
- switch (type_) {
- case LOG:
- return fast_log(input);
- default:
- UNREACHABLE();
- return 0.0; // Never happens.
- }
-}
-
-
-MaybeObject* TranscendentalCache::SubCache::Get(double input) {
- Converter c;
- c.dbl = input;
- int hash = Hash(c);
- Element e = elements_[hash];
- if (e.in[0] == c.integers[0] &&
- e.in[1] == c.integers[1]) {
- ASSERT(e.output != NULL);
- isolate_->counters()->transcendental_cache_hit()->Increment();
- return e.output;
- }
- double answer = Calculate(input);
- isolate_->counters()->transcendental_cache_miss()->Increment();
- Object* heap_number;
- { MaybeObject* maybe_heap_number =
- isolate_->heap()->AllocateHeapNumber(answer);
- if (!maybe_heap_number->ToObject(&heap_number)) return maybe_heap_number;
- }
- elements_[hash].in[0] = c.integers[0];
- elements_[hash].in[1] = c.integers[1];
- elements_[hash].output = heap_number;
- return heap_number;
-}
-
-
AlwaysAllocateScope::AlwaysAllocateScope() {
// We shouldn't hit any nested scopes, because that requires
// non-handle code to call handle code. The code still works but
diff --git a/src/heap-profiler.cc b/src/heap-profiler.cc
index 1e40950..7413b6e 100644
--- a/src/heap-profiler.cc
+++ b/src/heap-profiler.cc
@@ -212,4 +212,10 @@
}
+void HeapProfiler::ClearHeapObjectMap() {
+ ids_.Reset(new HeapObjectsMap(heap()));
+ if (!is_tracking_allocations()) is_tracking_object_moves_ = false;
+}
+
+
} } // namespace v8::internal
diff --git a/src/heap-profiler.h b/src/heap-profiler.h
index 6d15868..e4838df 100644
--- a/src/heap-profiler.h
+++ b/src/heap-profiler.h
@@ -87,6 +87,7 @@
}
Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id);
+ void ClearHeapObjectMap();
private:
Heap* heap() const { return ids_->heap(); }
diff --git a/src/heap.cc b/src/heap.cc
index 6921bb6..f6c6ae6 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -436,7 +436,6 @@
void Heap::GarbageCollectionPrologue() {
{ AllowHeapAllocation for_the_first_part_of_prologue;
- isolate_->transcendental_cache()->Clear();
ClearJSFunctionResultCaches();
gc_count_++;
unflattened_strings_length_ = 0;
@@ -7755,29 +7754,6 @@
#endif
-TranscendentalCache::SubCache::SubCache(Isolate* isolate, Type t)
- : type_(t),
- isolate_(isolate) {
- uint32_t in0 = 0xffffffffu; // Bit-pattern for a NaN that isn't
- uint32_t in1 = 0xffffffffu; // generated by the FPU.
- for (int i = 0; i < kCacheSize; i++) {
- elements_[i].in[0] = in0;
- elements_[i].in[1] = in1;
- elements_[i].output = NULL;
- }
-}
-
-
-void TranscendentalCache::Clear() {
- for (int i = 0; i < kNumberOfCaches; i++) {
- if (caches_[i] != NULL) {
- delete caches_[i];
- caches_[i] = NULL;
- }
- }
-}
-
-
void ExternalStringTable::CleanUp() {
int last = 0;
for (int i = 0; i < new_space_strings_.length(); ++i) {
diff --git a/src/heap.h b/src/heap.h
index d2d6961..871c4d8 100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -2894,85 +2894,6 @@
};
-class TranscendentalCache {
- public:
- enum Type { LOG, kNumberOfCaches};
- static const int kTranscendentalTypeBits = 3;
- STATIC_ASSERT((1 << kTranscendentalTypeBits) >= kNumberOfCaches);
-
- // Returns a heap number with f(input), where f is a math function specified
- // by the 'type' argument.
- MUST_USE_RESULT inline MaybeObject* Get(Type type, double input);
-
- // The cache contains raw Object pointers. This method disposes of
- // them before a garbage collection.
- void Clear();
-
- private:
- class SubCache {
- static const int kCacheSize = 512;
-
- explicit SubCache(Isolate* isolate, Type t);
-
- MUST_USE_RESULT inline MaybeObject* Get(double input);
-
- inline double Calculate(double input);
-
- struct Element {
- uint32_t in[2];
- Object* output;
- };
-
- union Converter {
- double dbl;
- uint32_t integers[2];
- };
-
- inline static int Hash(const Converter& c) {
- uint32_t hash = (c.integers[0] ^ c.integers[1]);
- hash ^= static_cast<int32_t>(hash) >> 16;
- hash ^= static_cast<int32_t>(hash) >> 8;
- return (hash & (kCacheSize - 1));
- }
-
- Element elements_[kCacheSize];
- Type type_;
- Isolate* isolate_;
-
- // Allow access to the caches_ array as an ExternalReference.
- friend class ExternalReference;
- // Inline implementation of the cache.
- friend class TranscendentalCacheStub;
- // For evaluating value.
- friend class TranscendentalCache;
-
- DISALLOW_COPY_AND_ASSIGN(SubCache);
- };
-
- explicit TranscendentalCache(Isolate* isolate) : isolate_(isolate) {
- for (int i = 0; i < kNumberOfCaches; ++i) caches_[i] = NULL;
- }
-
- ~TranscendentalCache() {
- for (int i = 0; i < kNumberOfCaches; ++i) delete caches_[i];
- }
-
- // Used to create an external reference.
- inline Address cache_array_address();
-
- // Instantiation
- friend class Isolate;
- // Inline implementation of the caching.
- friend class TranscendentalCacheStub;
- // Allow access to the caches_ array as an ExternalReference.
- friend class ExternalReference;
-
- Isolate* isolate_;
- SubCache* caches_[kNumberOfCaches];
- DISALLOW_COPY_AND_ASSIGN(TranscendentalCache);
-};
-
-
// Abstract base class for checking whether a weak object should be retained.
class WeakObjectRetainer {
public:
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index e7ad219..43235c2 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -3495,11 +3495,18 @@
dominator_allocate->clear_next_map_word_ = clear_next_map_word_;
// After that replace the dominated allocate instruction.
+ HInstruction* inner_offset = HConstant::CreateAndInsertBefore(
+ zone,
+ context(),
+ dominator_size_constant,
+ Representation::None(),
+ this);
+
HInstruction* dominated_allocate_instr =
HInnerAllocatedObject::New(zone,
context(),
dominator_allocate,
- dominator_size,
+ inner_offset,
type());
dominated_allocate_instr->InsertBefore(this);
DeleteAndReplaceWith(dominated_allocate_instr);
@@ -3873,7 +3880,7 @@
case kMathExp:
return H_CONSTANT_DOUBLE(fast_exp(d));
case kMathLog:
- return H_CONSTANT_DOUBLE(fast_log(d));
+ return H_CONSTANT_DOUBLE(log(d));
case kMathSqrt:
return H_CONSTANT_DOUBLE(fast_sqrt(d));
case kMathPowHalf:
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index 4dd24fd..df8d2dc 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -2682,10 +2682,6 @@
SetGVNFlag(kChangesNewSpacePromotion);
break;
case kMathLog:
- set_representation(Representation::Double());
- // These operations use the TranscendentalCache, so they may allocate.
- SetGVNFlag(kChangesNewSpacePromotion);
- break;
case kMathExp:
case kMathSqrt:
case kMathPowHalf:
@@ -5287,13 +5283,6 @@
HValue* context() { return value(); }
- void set_transcendental_type(TranscendentalCache::Type transcendental_type) {
- transcendental_type_ = transcendental_type;
- }
- TranscendentalCache::Type transcendental_type() {
- return transcendental_type_;
- }
-
virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
DECLARE_CONCRETE_INSTRUCTION(CallStub)
@@ -5301,12 +5290,10 @@
private:
HCallStub(HValue* context, CodeStub::Major major_key, int argument_count)
: HUnaryCall(context, argument_count),
- major_key_(major_key),
- transcendental_type_(TranscendentalCache::kNumberOfCaches) {
+ major_key_(major_key) {
}
CodeStub::Major major_key_;
- TranscendentalCache::Type transcendental_type_;
};
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 176dd9f..b3549f5 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -4136,45 +4136,27 @@
ASSERT(current_block() != NULL);
ASSERT(current_block()->HasPredecessor());
- // We only optimize switch statements with smi-literal smi comparisons,
- // with a bounded number of clauses.
+ // We only optimize switch statements with a bounded number of clauses.
const int kCaseClauseLimit = 128;
ZoneList<CaseClause*>* clauses = stmt->cases();
int clause_count = clauses->length();
+ ZoneList<HBasicBlock*> body_blocks(clause_count, zone());
if (clause_count > kCaseClauseLimit) {
return Bailout(kSwitchStatementTooManyClauses);
}
- ASSERT(stmt->switch_type() != SwitchStatement::UNKNOWN_SWITCH);
- if (stmt->switch_type() == SwitchStatement::GENERIC_SWITCH) {
- return Bailout(kSwitchStatementMixedOrNonLiteralSwitchLabels);
- }
-
CHECK_ALIVE(VisitForValue(stmt->tag()));
Add<HSimulate>(stmt->EntryId());
- HValue* tag_value = Pop();
- HBasicBlock* first_test_block = current_block();
-
- HUnaryControlInstruction* string_check = NULL;
- HBasicBlock* not_string_block = NULL;
-
- // Test switch's tag value if all clauses are string literals
- if (stmt->switch_type() == SwitchStatement::STRING_SWITCH) {
- first_test_block = graph()->CreateBasicBlock();
- not_string_block = graph()->CreateBasicBlock();
- string_check = New<HIsStringAndBranch>(
- tag_value, first_test_block, not_string_block);
- FinishCurrentBlock(string_check);
-
- set_current_block(first_test_block);
- }
+ HValue* tag_value = Top();
+ Handle<Type> tag_type = stmt->tag()->bounds().lower;
// 1. Build all the tests, with dangling true branches
BailoutId default_id = BailoutId::None();
for (int i = 0; i < clause_count; ++i) {
CaseClause* clause = clauses->at(i);
if (clause->is_default()) {
- default_id = clause->EntryId();
+ body_blocks.Add(NULL, zone());
+ if (default_id.IsNone()) default_id = clause->EntryId();
continue;
}
@@ -4182,48 +4164,33 @@
CHECK_ALIVE(VisitForValue(clause->label()));
HValue* label_value = Pop();
+ Handle<Type> label_type = clause->label()->bounds().lower;
+ Handle<Type> combined_type = clause->compare_type();
+ HControlInstruction* compare = BuildCompareInstruction(
+ Token::EQ_STRICT, tag_value, label_value, tag_type, label_type,
+ combined_type, stmt->tag()->position(), clause->label()->position(),
+ clause->id());
+
HBasicBlock* next_test_block = graph()->CreateBasicBlock();
HBasicBlock* body_block = graph()->CreateBasicBlock();
-
- HControlInstruction* compare;
-
- if (stmt->switch_type() == SwitchStatement::SMI_SWITCH) {
- if (!clause->compare_type()->Is(Type::Smi())) {
- Add<HDeoptimize>("Non-smi switch type", Deoptimizer::SOFT);
- }
-
- HCompareNumericAndBranch* compare_ =
- New<HCompareNumericAndBranch>(tag_value,
- label_value,
- Token::EQ_STRICT);
- compare_->set_observed_input_representation(
- Representation::Smi(), Representation::Smi());
- compare = compare_;
- } else {
- compare = New<HStringCompareAndBranch>(tag_value,
- label_value,
- Token::EQ_STRICT);
- }
-
+ body_blocks.Add(body_block, zone());
compare->SetSuccessorAt(0, body_block);
compare->SetSuccessorAt(1, next_test_block);
FinishCurrentBlock(compare);
+ set_current_block(body_block);
+ Drop(1); // tag_value
+
set_current_block(next_test_block);
}
// Save the current block to use for the default or to join with the
// exit.
HBasicBlock* last_block = current_block();
-
- if (not_string_block != NULL) {
- BailoutId join_id = !default_id.IsNone() ? default_id : stmt->ExitId();
- last_block = CreateJoin(last_block, not_string_block, join_id);
- }
+ Drop(1); // tag_value
// 2. Loop over the clauses and the linked list of tests in lockstep,
// translating the clause bodies.
- HBasicBlock* curr_test_block = first_test_block;
HBasicBlock* fall_through_block = NULL;
BreakAndContinueInfo break_info(stmt);
@@ -4235,40 +4202,16 @@
// goes to.
HBasicBlock* normal_block = NULL;
if (clause->is_default()) {
- if (last_block != NULL) {
- normal_block = last_block;
- last_block = NULL; // Cleared to indicate we've handled it.
- }
+ if (last_block == NULL) continue;
+ normal_block = last_block;
+ last_block = NULL; // Cleared to indicate we've handled it.
} else {
- // If the current test block is deoptimizing due to an unhandled clause
- // of the switch, the test instruction is in the next block since the
- // deopt must end the current block.
- if (curr_test_block->IsDeoptimizing()) {
- ASSERT(curr_test_block->end()->SecondSuccessor() == NULL);
- curr_test_block = curr_test_block->end()->FirstSuccessor();
- }
- normal_block = curr_test_block->end()->FirstSuccessor();
- curr_test_block = curr_test_block->end()->SecondSuccessor();
+ normal_block = body_blocks[i];
}
- // Identify a block to emit the body into.
- if (normal_block == NULL) {
- if (fall_through_block == NULL) {
- // (a) Unreachable.
- if (clause->is_default()) {
- continue; // Might still be reachable clause bodies.
- } else {
- break;
- }
- } else {
- // (b) Reachable only as fall through.
- set_current_block(fall_through_block);
- }
- } else if (fall_through_block == NULL) {
- // (c) Reachable only normally.
+ if (fall_through_block == NULL) {
set_current_block(normal_block);
} else {
- // (d) Reachable both ways.
HBasicBlock* join = CreateJoin(fall_through_block,
normal_block,
clause->EntryId());
@@ -9152,9 +9095,6 @@
Handle<Type> left_type = expr->left()->bounds().lower;
Handle<Type> right_type = expr->right()->bounds().lower;
Handle<Type> combined_type = expr->combined_type();
- Representation combined_rep = Representation::FromType(combined_type);
- Representation left_rep = Representation::FromType(left_type);
- Representation right_rep = Representation::FromType(right_type);
CHECK_ALIVE(VisitForValue(expr->left()));
CHECK_ALIVE(VisitForValue(expr->right()));
@@ -9228,34 +9168,54 @@
combined_type = left_type = right_type = handle(Type::Any(), isolate());
}
+ HControlInstruction* compare = BuildCompareInstruction(
+ op, left, right, left_type, right_type, combined_type,
+ expr->left()->position(), expr->right()->position(), expr->id());
+ if (compare == NULL) return; // Bailed out.
+ return ast_context()->ReturnControl(compare, expr->id());
+}
+
+
+HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction(
+ Token::Value op,
+ HValue* left,
+ HValue* right,
+ Handle<Type> left_type,
+ Handle<Type> right_type,
+ Handle<Type> combined_type,
+ int left_position,
+ int right_position,
+ BailoutId bailout_id) {
+ Representation left_rep = Representation::FromType(left_type);
+ Representation right_rep = Representation::FromType(right_type);
+ Representation combined_rep = Representation::FromType(combined_type);
+
if (combined_type->Is(Type::Receiver())) {
- switch (op) {
- case Token::EQ:
- case Token::EQ_STRICT: {
- // Can we get away with map check and not instance type check?
- if (combined_type->IsClass()) {
- Handle<Map> map = combined_type->AsClass();
- AddCheckMap(left, map);
- AddCheckMap(right, map);
- HCompareObjectEqAndBranch* result =
- New<HCompareObjectEqAndBranch>(left, right);
- if (FLAG_emit_opt_code_positions) {
- result->set_operand_position(zone(), 0, expr->left()->position());
- result->set_operand_position(zone(), 1, expr->right()->position());
- }
- return ast_context()->ReturnControl(result, expr->id());
- } else {
- BuildCheckHeapObject(left);
- Add<HCheckInstanceType>(left, HCheckInstanceType::IS_SPEC_OBJECT);
- BuildCheckHeapObject(right);
- Add<HCheckInstanceType>(right, HCheckInstanceType::IS_SPEC_OBJECT);
- HCompareObjectEqAndBranch* result =
- New<HCompareObjectEqAndBranch>(left, right);
- return ast_context()->ReturnControl(result, expr->id());
+ if (Token::IsEqualityOp(op)) {
+ // Can we get away with map check and not instance type check?
+ if (combined_type->IsClass()) {
+ Handle<Map> map = combined_type->AsClass();
+ AddCheckMap(left, map);
+ AddCheckMap(right, map);
+ HCompareObjectEqAndBranch* result =
+ New<HCompareObjectEqAndBranch>(left, right);
+ if (FLAG_emit_opt_code_positions) {
+ result->set_operand_position(zone(), 0, left_position);
+ result->set_operand_position(zone(), 1, right_position);
}
+ return result;
+ } else {
+ BuildCheckHeapObject(left);
+ Add<HCheckInstanceType>(left, HCheckInstanceType::IS_SPEC_OBJECT);
+ BuildCheckHeapObject(right);
+ Add<HCheckInstanceType>(right, HCheckInstanceType::IS_SPEC_OBJECT);
+ HCompareObjectEqAndBranch* result =
+ New<HCompareObjectEqAndBranch>(left, right);
+ return result;
}
- default:
- return Bailout(kUnsupportedNonPrimitiveCompare);
+ } else {
+ Bailout(kUnsupportedNonPrimitiveCompare);
+ return NULL;
}
} else if (combined_type->Is(Type::InternalizedString()) &&
Token::IsEqualityOp(op)) {
@@ -9265,7 +9225,7 @@
Add<HCheckInstanceType>(right, HCheckInstanceType::IS_INTERNALIZED_STRING);
HCompareObjectEqAndBranch* result =
New<HCompareObjectEqAndBranch>(left, right);
- return ast_context()->ReturnControl(result, expr->id());
+ return result;
} else if (combined_type->Is(Type::String())) {
BuildCheckHeapObject(left);
Add<HCheckInstanceType>(left, HCheckInstanceType::IS_STRING);
@@ -9273,23 +9233,28 @@
Add<HCheckInstanceType>(right, HCheckInstanceType::IS_STRING);
HStringCompareAndBranch* result =
New<HStringCompareAndBranch>(left, right, op);
- return ast_context()->ReturnControl(result, expr->id());
+ return result;
} else {
if (combined_rep.IsTagged() || combined_rep.IsNone()) {
- HCompareGeneric* result = New<HCompareGeneric>(left, right, op);
+ HCompareGeneric* result = Add<HCompareGeneric>(left, right, op);
result->set_observed_input_representation(1, left_rep);
result->set_observed_input_representation(2, right_rep);
- return ast_context()->ReturnInstruction(result, expr->id());
+ if (result->HasObservableSideEffects()) {
+ Push(result);
+ AddSimulate(bailout_id, REMOVABLE_SIMULATE);
+ Drop(1);
+ }
+ // TODO(jkummerow): Can we make this more efficient?
+ HBranch* branch = New<HBranch>(result);
+ return branch;
} else {
HCompareNumericAndBranch* result =
New<HCompareNumericAndBranch>(left, right, op);
result->set_observed_input_representation(left_rep, right_rep);
if (FLAG_emit_opt_code_positions) {
- result->SetOperandPositions(zone(),
- expr->left()->position(),
- expr->right()->position());
+ result->SetOperandPositions(zone(), left_position, right_position);
}
- return ast_context()->ReturnControl(result, expr->id());
+ return result;
}
}
}
@@ -10146,11 +10111,10 @@
void HOptimizedGraphBuilder::GenerateMathLog(CallRuntime* call) {
- ASSERT_EQ(1, call->arguments()->length());
- CHECK_ALIVE(VisitArgumentList(call->arguments()));
- HCallStub* result = New<HCallStub>(CodeStub::TranscendentalCache, 1);
- result->set_transcendental_type(TranscendentalCache::LOG);
- Drop(1);
+ ASSERT(call->arguments()->length() == 1);
+ CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
+ HValue* value = Pop();
+ HInstruction* result = NewUncasted<HUnaryMathOperation>(value, kMathLog);
return ast_context()->ReturnInstruction(result, call->id());
}
diff --git a/src/hydrogen.h b/src/hydrogen.h
index 61e98b2..b2fd14c 100644
--- a/src/hydrogen.h
+++ b/src/hydrogen.h
@@ -2323,6 +2323,15 @@
void HandleLiteralCompareNil(CompareOperation* expr,
Expression* sub_expr,
NilValue nil);
+ HControlInstruction* BuildCompareInstruction(Token::Value op,
+ HValue* left,
+ HValue* right,
+ Handle<Type> left_type,
+ Handle<Type> right_type,
+ Handle<Type> combined_type,
+ int left_position,
+ int right_position,
+ BailoutId bailout_id);
HInstruction* BuildStringCharCodeAt(HValue* string,
HValue* index);
diff --git a/src/i18n.cc b/src/i18n.cc
index 80a739c..f340cc0 100644
--- a/src/i18n.cc
+++ b/src/i18n.cc
@@ -864,15 +864,24 @@
}
-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 @@
}
-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 @@
}
-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 @@
}
-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
diff --git a/src/i18n.h b/src/i18n.h
index 08e7f2b..50beb49 100644
--- a/src/i18n.h
+++ b/src/i18n.h
@@ -71,9 +71,9 @@
// 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 @@
// 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 @@
// 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 @@
// 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();
diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc
index 4633400..208bd91 100644
--- a/src/ia32/code-stubs-ia32.cc
+++ b/src/ia32/code-stubs-ia32.cc
@@ -695,228 +695,6 @@
}
-void TranscendentalCacheStub::Generate(MacroAssembler* masm) {
- // TAGGED case:
- // Input:
- // esp[4]: tagged number input argument (should be number).
- // esp[0]: return address.
- // Output:
- // eax: tagged double result.
- // UNTAGGED case:
- // Input::
- // esp[0]: return address.
- // xmm1: untagged double input argument
- // Output:
- // xmm1: untagged double result.
-
- Label runtime_call;
- Label runtime_call_clear_stack;
- Label skip_cache;
- const bool tagged = (argument_type_ == TAGGED);
- if (tagged) {
- // Test that eax is a number.
- Label input_not_smi;
- Label loaded;
- __ mov(eax, Operand(esp, kPointerSize));
- __ JumpIfNotSmi(eax, &input_not_smi, Label::kNear);
- // Input is a smi. Untag and load it onto the FPU stack.
- // Then load the low and high words of the double into ebx, edx.
- STATIC_ASSERT(kSmiTagSize == 1);
- __ sar(eax, 1);
- __ sub(esp, Immediate(2 * kPointerSize));
- __ mov(Operand(esp, 0), eax);
- __ fild_s(Operand(esp, 0));
- __ fst_d(Operand(esp, 0));
- __ pop(edx);
- __ pop(ebx);
- __ jmp(&loaded, Label::kNear);
- __ bind(&input_not_smi);
- // Check if input is a HeapNumber.
- __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
- Factory* factory = masm->isolate()->factory();
- __ cmp(ebx, Immediate(factory->heap_number_map()));
- __ j(not_equal, &runtime_call);
- // Input is a HeapNumber. Push it on the FPU stack and load its
- // low and high words into ebx, edx.
- __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset));
- __ mov(edx, FieldOperand(eax, HeapNumber::kExponentOffset));
- __ mov(ebx, FieldOperand(eax, HeapNumber::kMantissaOffset));
-
- __ bind(&loaded);
- } else { // UNTAGGED.
- CpuFeatureScope scope(masm, SSE2);
- if (CpuFeatures::IsSupported(SSE4_1)) {
- CpuFeatureScope sse4_scope(masm, SSE4_1);
- __ pextrd(edx, xmm1, 0x1); // copy xmm1[63..32] to edx.
- } else {
- __ pshufd(xmm0, xmm1, 0x1);
- __ movd(edx, xmm0);
- }
- __ movd(ebx, xmm1);
- }
-
- // ST[0] or xmm1 == double value
- // ebx = low 32 bits of double value
- // edx = high 32 bits of double value
- // Compute hash (the shifts are arithmetic):
- // h = (low ^ high); h ^= h >> 16; h ^= h >> 8; h = h & (cacheSize - 1);
- __ mov(ecx, ebx);
- __ xor_(ecx, edx);
- __ mov(eax, ecx);
- __ sar(eax, 16);
- __ xor_(ecx, eax);
- __ mov(eax, ecx);
- __ sar(eax, 8);
- __ xor_(ecx, eax);
- ASSERT(IsPowerOf2(TranscendentalCache::SubCache::kCacheSize));
- __ and_(ecx,
- Immediate(TranscendentalCache::SubCache::kCacheSize - 1));
-
- // ST[0] or xmm1 == double value.
- // ebx = low 32 bits of double value.
- // edx = high 32 bits of double value.
- // ecx = TranscendentalCache::hash(double value).
- ExternalReference cache_array =
- ExternalReference::transcendental_cache_array_address(masm->isolate());
- __ mov(eax, Immediate(cache_array));
- int cache_array_index =
- type_ * sizeof(masm->isolate()->transcendental_cache()->caches_[0]);
- __ mov(eax, Operand(eax, cache_array_index));
- // Eax points to the cache for the type type_.
- // If NULL, the cache hasn't been initialized yet, so go through runtime.
- __ test(eax, eax);
- __ j(zero, &runtime_call_clear_stack);
-#ifdef DEBUG
- // Check that the layout of cache elements match expectations.
- { TranscendentalCache::SubCache::Element test_elem[2];
- char* elem_start = reinterpret_cast<char*>(&test_elem[0]);
- char* elem2_start = reinterpret_cast<char*>(&test_elem[1]);
- char* elem_in0 = reinterpret_cast<char*>(&(test_elem[0].in[0]));
- char* elem_in1 = reinterpret_cast<char*>(&(test_elem[0].in[1]));
- char* elem_out = reinterpret_cast<char*>(&(test_elem[0].output));
- CHECK_EQ(12, elem2_start - elem_start); // Two uint_32's and a pointer.
- CHECK_EQ(0, elem_in0 - elem_start);
- CHECK_EQ(kIntSize, elem_in1 - elem_start);
- CHECK_EQ(2 * kIntSize, elem_out - elem_start);
- }
-#endif
- // Find the address of the ecx'th entry in the cache, i.e., &eax[ecx*12].
- __ lea(ecx, Operand(ecx, ecx, times_2, 0));
- __ lea(ecx, Operand(eax, ecx, times_4, 0));
- // Check if cache matches: Double value is stored in uint32_t[2] array.
- Label cache_miss;
- __ cmp(ebx, Operand(ecx, 0));
- __ j(not_equal, &cache_miss, Label::kNear);
- __ cmp(edx, Operand(ecx, kIntSize));
- __ j(not_equal, &cache_miss, Label::kNear);
- // Cache hit!
- Counters* counters = masm->isolate()->counters();
- __ IncrementCounter(counters->transcendental_cache_hit(), 1);
- __ mov(eax, Operand(ecx, 2 * kIntSize));
- if (tagged) {
- __ fstp(0);
- __ ret(kPointerSize);
- } else { // UNTAGGED.
- CpuFeatureScope scope(masm, SSE2);
- __ movsd(xmm1, FieldOperand(eax, HeapNumber::kValueOffset));
- __ Ret();
- }
-
- __ bind(&cache_miss);
- __ IncrementCounter(counters->transcendental_cache_miss(), 1);
- // Update cache with new value.
- // We are short on registers, so use no_reg as scratch.
- // This gives slightly larger code.
- if (tagged) {
- __ AllocateHeapNumber(eax, edi, no_reg, &runtime_call_clear_stack);
- } else { // UNTAGGED.
- CpuFeatureScope scope(masm, SSE2);
- __ AllocateHeapNumber(eax, edi, no_reg, &skip_cache);
- __ sub(esp, Immediate(kDoubleSize));
- __ movsd(Operand(esp, 0), xmm1);
- __ fld_d(Operand(esp, 0));
- __ add(esp, Immediate(kDoubleSize));
- }
- GenerateOperation(masm, type_);
- __ mov(Operand(ecx, 0), ebx);
- __ mov(Operand(ecx, kIntSize), edx);
- __ mov(Operand(ecx, 2 * kIntSize), eax);
- __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset));
- if (tagged) {
- __ ret(kPointerSize);
- } else { // UNTAGGED.
- CpuFeatureScope scope(masm, SSE2);
- __ movsd(xmm1, FieldOperand(eax, HeapNumber::kValueOffset));
- __ Ret();
-
- // Skip cache and return answer directly, only in untagged case.
- __ bind(&skip_cache);
- __ sub(esp, Immediate(kDoubleSize));
- __ movsd(Operand(esp, 0), xmm1);
- __ fld_d(Operand(esp, 0));
- GenerateOperation(masm, type_);
- __ fstp_d(Operand(esp, 0));
- __ movsd(xmm1, Operand(esp, 0));
- __ add(esp, Immediate(kDoubleSize));
- // We return the value in xmm1 without adding it to the cache, but
- // we cause a scavenging GC so that future allocations will succeed.
- {
- FrameScope scope(masm, StackFrame::INTERNAL);
- // Allocate an unused object bigger than a HeapNumber.
- __ push(Immediate(Smi::FromInt(2 * kDoubleSize)));
- __ CallRuntimeSaveDoubles(Runtime::kAllocateInNewSpace);
- }
- __ Ret();
- }
-
- // Call runtime, doing whatever allocation and cleanup is necessary.
- if (tagged) {
- __ bind(&runtime_call_clear_stack);
- __ fstp(0);
- __ bind(&runtime_call);
- ExternalReference runtime =
- ExternalReference(RuntimeFunction(), masm->isolate());
- __ TailCallExternalReference(runtime, 1, 1);
- } else { // UNTAGGED.
- CpuFeatureScope scope(masm, SSE2);
- __ bind(&runtime_call_clear_stack);
- __ bind(&runtime_call);
- __ AllocateHeapNumber(eax, edi, no_reg, &skip_cache);
- __ movsd(FieldOperand(eax, HeapNumber::kValueOffset), xmm1);
- {
- FrameScope scope(masm, StackFrame::INTERNAL);
- __ push(eax);
- __ CallRuntime(RuntimeFunction(), 1);
- }
- __ movsd(xmm1, FieldOperand(eax, HeapNumber::kValueOffset));
- __ Ret();
- }
-}
-
-
-Runtime::FunctionId TranscendentalCacheStub::RuntimeFunction() {
- switch (type_) {
- case TranscendentalCache::LOG: return Runtime::kMath_log;
- default:
- UNIMPLEMENTED();
- return Runtime::kAbort;
- }
-}
-
-
-void TranscendentalCacheStub::GenerateOperation(
- MacroAssembler* masm, TranscendentalCache::Type type) {
- // Only free register is edi.
- // Input value is on FP stack, and also in ebx/edx.
- // Input value is possibly in xmm1.
- // Address of result (a newly allocated HeapNumber) may be in eax.
- ASSERT(type == TranscendentalCache::LOG);
- __ fldln2();
- __ fxch();
- __ fyl2x();
-}
-
-
void FloatingPointHelper::LoadFloatOperand(MacroAssembler* masm,
Register number) {
Label load_smi, done;
diff --git a/src/ia32/code-stubs-ia32.h b/src/ia32/code-stubs-ia32.h
index 1425924..0982fe1 100644
--- a/src/ia32/code-stubs-ia32.h
+++ b/src/ia32/code-stubs-ia32.h
@@ -40,30 +40,6 @@
bool construct_call,
Label* call_generic_code);
-// Compute a transcendental math function natively, or call the
-// TranscendentalCache runtime function.
-class TranscendentalCacheStub: public PlatformCodeStub {
- public:
- enum ArgumentType {
- TAGGED = 0,
- UNTAGGED = 1 << TranscendentalCache::kTranscendentalTypeBits
- };
-
- TranscendentalCacheStub(TranscendentalCache::Type type,
- ArgumentType argument_type)
- : type_(type), argument_type_(argument_type) {}
- void Generate(MacroAssembler* masm);
- static void GenerateOperation(MacroAssembler* masm,
- TranscendentalCache::Type type);
- private:
- TranscendentalCache::Type type_;
- ArgumentType argument_type_;
-
- Major MajorKey() { return TranscendentalCache; }
- int MinorKey() { return type_ | argument_type_; }
- Runtime::FunctionId RuntimeFunction();
-};
-
class StoreBufferOverflowStub: public PlatformCodeStub {
public:
diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc
index 84187b0..99dbe20 100644
--- a/src/ia32/codegen-ia32.cc
+++ b/src/ia32/codegen-ia32.cc
@@ -57,48 +57,6 @@
#define __ masm.
-UnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type) {
- size_t actual_size;
- // Allocate buffer in executable space.
- byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB,
- &actual_size,
- true));
- if (buffer == NULL) {
- // Fallback to library function if function cannot be created.
- switch (type) {
- case TranscendentalCache::LOG: return &log;
- default: UNIMPLEMENTED();
- }
- }
-
- MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
- // esp[1 * kPointerSize]: raw double input
- // esp[0 * kPointerSize]: return address
- // Move double input into registers.
-
- __ push(ebx);
- __ push(edx);
- __ push(edi);
- __ fld_d(Operand(esp, 4 * kPointerSize));
- __ mov(ebx, Operand(esp, 4 * kPointerSize));
- __ mov(edx, Operand(esp, 5 * kPointerSize));
- TranscendentalCacheStub::GenerateOperation(&masm, type);
- // The return value is expected to be on ST(0) of the FPU stack.
- __ pop(edi);
- __ pop(edx);
- __ pop(ebx);
- __ Ret();
-
- CodeDesc desc;
- masm.GetCode(&desc);
- ASSERT(!RelocInfo::RequiresRelocation(desc));
-
- CPU::FlushICache(buffer, actual_size);
- OS::ProtectCode(buffer, actual_size);
- return FUNCTION_CAST<UnaryMathFunction>(buffer);
-}
-
-
UnaryMathFunction CreateExpFunction() {
if (!CpuFeatures::IsSupported(SSE2)) return &exp;
if (!FLAG_fast_math) return &exp;
diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc
index 3c92afa..e43e525 100644
--- a/src/ia32/full-codegen-ia32.cc
+++ b/src/ia32/full-codegen-ia32.cc
@@ -977,6 +977,16 @@
Handle<Code> ic = CompareIC::GetUninitialized(isolate(), Token::EQ_STRICT);
CallIC(ic, RelocInfo::CODE_TARGET, clause->CompareId());
patch_site.EmitPatchInfo();
+
+ Label skip;
+ __ jmp(&skip, Label::kNear);
+ PrepareForBailout(clause, TOS_REG);
+ __ cmp(eax, isolate()->factory()->true_value());
+ __ j(not_equal, &next_test);
+ __ Drop(1);
+ __ jmp(clause->body_target());
+ __ bind(&skip);
+
__ test(eax, eax);
__ j(not_equal, &next_test);
__ Drop(1); // Switch value is no longer needed.
@@ -3660,13 +3670,11 @@
void FullCodeGenerator::EmitMathLog(CallRuntime* expr) {
- // Load the argument on the stack and call the stub.
- TranscendentalCacheStub stub(TranscendentalCache::LOG,
- TranscendentalCacheStub::TAGGED);
+ // Load the argument on the stack and call the runtime function.
ZoneList<Expression*>* args = expr->arguments();
ASSERT(args->length() == 1);
VisitForStackValue(args->at(0));
- __ CallStub(&stub);
+ __ CallRuntime(Runtime::kMath_log, 1);
context()->Plug(eax);
}
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc
index bba3aca..86118eb 100644
--- a/src/ia32/lithium-codegen-ia32.cc
+++ b/src/ia32/lithium-codegen-ia32.cc
@@ -1349,12 +1349,6 @@
CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
break;
}
- case CodeStub::TranscendentalCache: {
- TranscendentalCacheStub stub(instr->transcendental_type(),
- TranscendentalCacheStub::TAGGED);
- CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
- break;
- }
default:
UNREACHABLE();
}
@@ -2259,7 +2253,7 @@
__ movsd(Operand(esp, 0 * kDoubleSize), left);
__ movsd(Operand(esp, 1 * kDoubleSize), right);
__ CallCFunction(
- ExternalReference::double_fp_operation(Token::MOD, isolate()),
+ ExternalReference::mod_two_doubles_operation(isolate()),
4);
// Return value is in st(0) on ia32.
@@ -2303,7 +2297,7 @@
ASSERT(left.is(result));
X87PrepareToWrite(result);
__ CallCFunction(
- ExternalReference::double_fp_operation(Token::MOD, isolate()),
+ ExternalReference::mod_two_doubles_operation(isolate()),
4);
// Return value is in st(0) on ia32.
@@ -4162,7 +4156,7 @@
__ xorps(xmm_scratch, xmm_scratch);
__ ucomisd(input_reg, xmm_scratch);
__ j(above, &positive, Label::kNear);
- __ j(equal, &zero, Label::kNear);
+ __ j(not_carry, &zero, Label::kNear);
ExternalReference nan =
ExternalReference::address_of_canonical_non_hole_nan();
__ movsd(input_reg, Operand::StaticVariable(nan));
diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc
index aca9bdf..6e720f1 100644
--- a/src/ia32/lithium-ia32.cc
+++ b/src/ia32/lithium-ia32.cc
@@ -1309,8 +1309,7 @@
ASSERT(instr->representation().IsDouble());
ASSERT(instr->value()->representation().IsDouble());
LOperand* input = UseRegisterAtStart(instr->value());
- LMathLog* result = new(zone()) LMathLog(input);
- return DefineSameAsFirst(result);
+ return MarkAsCall(DefineSameAsFirst(new(zone()) LMathLog(input)), instr);
}
diff --git a/src/ia32/lithium-ia32.h b/src/ia32/lithium-ia32.h
index 912ec1e..31a1e62 100644
--- a/src/ia32/lithium-ia32.h
+++ b/src/ia32/lithium-ia32.h
@@ -498,10 +498,6 @@
DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
DECLARE_HYDROGEN_ACCESSOR(CallStub)
-
- TranscendentalCache::Type transcendental_type() {
- return hydrogen()->transcendental_type();
- }
};
diff --git a/src/isolate.cc b/src/isolate.cc
index a0dd958..9ecc7ef 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -1532,7 +1532,6 @@
capture_stack_trace_for_uncaught_exceptions_(false),
stack_trace_for_uncaught_exceptions_frame_limit_(0),
stack_trace_for_uncaught_exceptions_options_(StackTrace::kOverview),
- transcendental_cache_(NULL),
memory_allocator_(NULL),
keyed_lookup_cache_(NULL),
context_slot_cache_(NULL),
@@ -1769,8 +1768,6 @@
delete keyed_lookup_cache_;
keyed_lookup_cache_ = NULL;
- delete transcendental_cache_;
- transcendental_cache_ = NULL;
delete stub_cache_;
stub_cache_ = NULL;
delete stats_table_;
@@ -1935,7 +1932,6 @@
string_tracker_ = new StringTracker();
string_tracker_->isolate_ = this;
compilation_cache_ = new CompilationCache(this);
- transcendental_cache_ = new TranscendentalCache(this);
keyed_lookup_cache_ = new KeyedLookupCache();
context_slot_cache_ = new ContextSlotCache();
descriptor_lookup_cache_ = new DescriptorLookupCache();
diff --git a/src/isolate.h b/src/isolate.h
index 7ba3088..31a0af8 100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -870,10 +870,6 @@
DeoptimizerData* deoptimizer_data() { return deoptimizer_data_; }
ThreadLocalTop* thread_local_top() { return &thread_local_top_; }
- TranscendentalCache* transcendental_cache() const {
- return transcendental_cache_;
- }
-
MemoryAllocator* memory_allocator() {
return memory_allocator_;
}
@@ -1270,7 +1266,6 @@
bool capture_stack_trace_for_uncaught_exceptions_;
int stack_trace_for_uncaught_exceptions_frame_limit_;
StackTrace::StackTraceOptions stack_trace_for_uncaught_exceptions_options_;
- TranscendentalCache* transcendental_cache_;
MemoryAllocator* memory_allocator_;
KeyedLookupCache* keyed_lookup_cache_;
ContextSlotCache* context_slot_cache_;
diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc
index cd1af91..ca765aa 100644
--- a/src/mips/code-stubs-mips.cc
+++ b/src/mips/code-stubs-mips.cc
@@ -1273,224 +1273,6 @@
}
-void TranscendentalCacheStub::Generate(MacroAssembler* masm) {
- // Untagged case: double input in f4, double result goes
- // into f4.
- // Tagged case: tagged input on top of stack and in a0,
- // tagged result (heap number) goes into v0.
-
- Label input_not_smi;
- Label loaded;
- Label calculate;
- Label invalid_cache;
- const Register scratch0 = t5;
- const Register scratch1 = t3;
- const Register cache_entry = a0;
- const bool tagged = (argument_type_ == TAGGED);
-
- if (tagged) {
- // Argument is a number and is on stack and in a0.
- // Load argument and check if it is a smi.
- __ JumpIfNotSmi(a0, &input_not_smi);
-
- // Input is a smi. Convert to double and load the low and high words
- // of the double into a2, a3.
- __ sra(t0, a0, kSmiTagSize);
- __ mtc1(t0, f4);
- __ cvt_d_w(f4, f4);
- __ Move(a2, a3, f4);
- __ Branch(&loaded);
-
- __ bind(&input_not_smi);
- // Check if input is a HeapNumber.
- __ CheckMap(a0,
- a1,
- Heap::kHeapNumberMapRootIndex,
- &calculate,
- DONT_DO_SMI_CHECK);
- // Input is a HeapNumber. Store the
- // low and high words into a2, a3.
- __ lw(a2, FieldMemOperand(a0, HeapNumber::kValueOffset));
- __ lw(a3, FieldMemOperand(a0, HeapNumber::kValueOffset + 4));
- } else {
- // Input is untagged double in f4. Output goes to f4.
- __ Move(a2, a3, f4);
- }
- __ bind(&loaded);
- // a2 = low 32 bits of double value.
- // a3 = high 32 bits of double value.
- // Compute hash (the shifts are arithmetic):
- // h = (low ^ high); h ^= h >> 16; h ^= h >> 8; h = h & (cacheSize - 1);
- __ Xor(a1, a2, a3);
- __ sra(t0, a1, 16);
- __ Xor(a1, a1, t0);
- __ sra(t0, a1, 8);
- __ Xor(a1, a1, t0);
- ASSERT(IsPowerOf2(TranscendentalCache::SubCache::kCacheSize));
- __ And(a1, a1, Operand(TranscendentalCache::SubCache::kCacheSize - 1));
-
- // a2 = low 32 bits of double value.
- // a3 = high 32 bits of double value.
- // a1 = TranscendentalCache::hash(double value).
- __ li(cache_entry, Operand(
- ExternalReference::transcendental_cache_array_address(
- masm->isolate())));
- // a0 points to cache array.
- __ lw(cache_entry, MemOperand(cache_entry, type_ * sizeof(
- Isolate::Current()->transcendental_cache()->caches_[0])));
- // a0 points to the cache for the type type_.
- // If NULL, the cache hasn't been initialized yet, so go through runtime.
- __ Branch(&invalid_cache, eq, cache_entry, Operand(zero_reg));
-
-#ifdef DEBUG
- // Check that the layout of cache elements match expectations.
- { TranscendentalCache::SubCache::Element test_elem[2];
- char* elem_start = reinterpret_cast<char*>(&test_elem[0]);
- char* elem2_start = reinterpret_cast<char*>(&test_elem[1]);
- char* elem_in0 = reinterpret_cast<char*>(&(test_elem[0].in[0]));
- char* elem_in1 = reinterpret_cast<char*>(&(test_elem[0].in[1]));
- char* elem_out = reinterpret_cast<char*>(&(test_elem[0].output));
- CHECK_EQ(12, elem2_start - elem_start); // Two uint_32's and a pointer.
- CHECK_EQ(0, elem_in0 - elem_start);
- CHECK_EQ(kIntSize, elem_in1 - elem_start);
- CHECK_EQ(2 * kIntSize, elem_out - elem_start);
- }
-#endif
-
- // Find the address of the a1'st entry in the cache, i.e., &a0[a1*12].
- __ sll(t0, a1, 1);
- __ Addu(a1, a1, t0);
- __ sll(t0, a1, 2);
- __ Addu(cache_entry, cache_entry, t0);
-
- // Check if cache matches: Double value is stored in uint32_t[2] array.
- __ lw(t0, MemOperand(cache_entry, 0));
- __ lw(t1, MemOperand(cache_entry, 4));
- __ lw(t2, MemOperand(cache_entry, 8));
- __ Branch(&calculate, ne, a2, Operand(t0));
- __ Branch(&calculate, ne, a3, Operand(t1));
- // Cache hit. Load result, cleanup and return.
- Counters* counters = masm->isolate()->counters();
- __ IncrementCounter(
- counters->transcendental_cache_hit(), 1, scratch0, scratch1);
- if (tagged) {
- // Pop input value from stack and load result into v0.
- __ Drop(1);
- __ mov(v0, t2);
- } else {
- // Load result into f4.
- __ ldc1(f4, FieldMemOperand(t2, HeapNumber::kValueOffset));
- }
- __ Ret();
-
- __ bind(&calculate);
- __ IncrementCounter(
- counters->transcendental_cache_miss(), 1, scratch0, scratch1);
- if (tagged) {
- __ bind(&invalid_cache);
- __ TailCallExternalReference(ExternalReference(RuntimeFunction(),
- masm->isolate()),
- 1,
- 1);
- } else {
- Label no_update;
- Label skip_cache;
-
- // Call C function to calculate the result and update the cache.
- // a0: precalculated cache entry address.
- // a2 and a3: parts of the double value.
- // Store a0, a2 and a3 on stack for later before calling C function.
- __ Push(a3, a2, cache_entry);
- GenerateCallCFunction(masm, scratch0);
- __ GetCFunctionDoubleResult(f4);
-
- // Try to update the cache. If we cannot allocate a
- // heap number, we return the result without updating.
- __ Pop(a3, a2, cache_entry);
- __ LoadRoot(t1, Heap::kHeapNumberMapRootIndex);
- __ AllocateHeapNumber(t2, scratch0, scratch1, t1, &no_update);
- __ sdc1(f4, FieldMemOperand(t2, HeapNumber::kValueOffset));
-
- __ sw(a2, MemOperand(cache_entry, 0 * kPointerSize));
- __ sw(a3, MemOperand(cache_entry, 1 * kPointerSize));
- __ sw(t2, MemOperand(cache_entry, 2 * kPointerSize));
-
- __ Ret(USE_DELAY_SLOT);
- __ mov(v0, cache_entry);
-
- __ bind(&invalid_cache);
- // The cache is invalid. Call runtime which will recreate the
- // cache.
- __ LoadRoot(t1, Heap::kHeapNumberMapRootIndex);
- __ AllocateHeapNumber(a0, scratch0, scratch1, t1, &skip_cache);
- __ sdc1(f4, FieldMemOperand(a0, HeapNumber::kValueOffset));
- {
- FrameScope scope(masm, StackFrame::INTERNAL);
- __ push(a0);
- __ CallRuntime(RuntimeFunction(), 1);
- }
- __ ldc1(f4, FieldMemOperand(v0, HeapNumber::kValueOffset));
- __ Ret();
-
- __ bind(&skip_cache);
- // Call C function to calculate the result and answer directly
- // without updating the cache.
- GenerateCallCFunction(masm, scratch0);
- __ GetCFunctionDoubleResult(f4);
- __ bind(&no_update);
-
- // We return the value in f4 without adding it to the cache, but
- // we cause a scavenging GC so that future allocations will succeed.
- {
- FrameScope scope(masm, StackFrame::INTERNAL);
-
- // Allocate an aligned object larger than a HeapNumber.
- ASSERT(4 * kPointerSize >= HeapNumber::kSize);
- __ li(scratch0, Operand(4 * kPointerSize));
- __ push(scratch0);
- __ CallRuntimeSaveDoubles(Runtime::kAllocateInNewSpace);
- }
- __ Ret();
- }
-}
-
-
-void TranscendentalCacheStub::GenerateCallCFunction(MacroAssembler* masm,
- Register scratch) {
- __ push(ra);
- __ PrepareCallCFunction(2, scratch);
- if (IsMipsSoftFloatABI) {
- __ Move(a0, a1, f4);
- } else {
- __ mov_d(f12, f4);
- }
- AllowExternalCallThatCantCauseGC scope(masm);
- Isolate* isolate = masm->isolate();
- switch (type_) {
- case TranscendentalCache::LOG:
- __ CallCFunction(
- ExternalReference::math_log_double_function(isolate),
- 0, 1);
- break;
- default:
- UNIMPLEMENTED();
- break;
- }
- __ pop(ra);
-}
-
-
-Runtime::FunctionId TranscendentalCacheStub::RuntimeFunction() {
- switch (type_) {
- // Add more cases when necessary.
- case TranscendentalCache::LOG: return Runtime::kMath_log;
- default:
- UNIMPLEMENTED();
- return Runtime::kAbort;
- }
-}
-
-
void MathPowStub::Generate(MacroAssembler* masm) {
const Register base = a1;
const Register exponent = a2;
diff --git a/src/mips/code-stubs-mips.h b/src/mips/code-stubs-mips.h
index c3e05b8..a0e01b2 100644
--- a/src/mips/code-stubs-mips.h
+++ b/src/mips/code-stubs-mips.h
@@ -38,30 +38,6 @@
void ArrayNativeCode(MacroAssembler* masm, Label* call_generic_code);
-// Compute a transcendental math function natively, or call the
-// TranscendentalCache runtime function.
-class TranscendentalCacheStub: public PlatformCodeStub {
- public:
- enum ArgumentType {
- TAGGED = 0 << TranscendentalCache::kTranscendentalTypeBits,
- UNTAGGED = 1 << TranscendentalCache::kTranscendentalTypeBits
- };
-
- TranscendentalCacheStub(TranscendentalCache::Type type,
- ArgumentType argument_type)
- : type_(type), argument_type_(argument_type) { }
- void Generate(MacroAssembler* masm);
- private:
- TranscendentalCache::Type type_;
- ArgumentType argument_type_;
- void GenerateCallCFunction(MacroAssembler* masm, Register scratch);
-
- Major MajorKey() { return TranscendentalCache; }
- int MinorKey() { return type_ | argument_type_; }
- Runtime::FunctionId RuntimeFunction();
-};
-
-
class StoreBufferOverflowStub: public PlatformCodeStub {
public:
explicit StoreBufferOverflowStub(SaveFPRegsMode save_fp)
diff --git a/src/mips/codegen-mips.cc b/src/mips/codegen-mips.cc
index cd3a24f..7a20712 100644
--- a/src/mips/codegen-mips.cc
+++ b/src/mips/codegen-mips.cc
@@ -37,15 +37,6 @@
namespace internal {
-UnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type) {
- switch (type) {
- case TranscendentalCache::LOG: return &log;
- default: UNIMPLEMENTED();
- }
- return NULL;
-}
-
-
#define __ masm.
diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc
index 74b3807..4b6d280 100644
--- a/src/mips/full-codegen-mips.cc
+++ b/src/mips/full-codegen-mips.cc
@@ -1039,6 +1039,15 @@
CallIC(ic, RelocInfo::CODE_TARGET, clause->CompareId());
patch_site.EmitPatchInfo();
+ Label skip;
+ __ b(&skip);
+ PrepareForBailout(clause, TOS_REG);
+ __ LoadRoot(at, Heap::kTrueValueRootIndex);
+ __ Branch(&next_test, ne, v0, Operand(at));
+ __ Drop(1);
+ __ jmp(clause->body_target());
+ __ bind(&skip);
+
__ Branch(&next_test, ne, v0, Operand(zero_reg));
__ Drop(1); // Switch value is no longer needed.
__ Branch(clause->body_target());
@@ -3748,14 +3757,11 @@
void FullCodeGenerator::EmitMathLog(CallRuntime* expr) {
- // Load the argument on the stack and call the stub.
- TranscendentalCacheStub stub(TranscendentalCache::LOG,
- TranscendentalCacheStub::TAGGED);
+ // Load the argument on the stack and call the runtime function.
ZoneList<Expression*>* args = expr->arguments();
ASSERT(args->length() == 1);
VisitForStackValue(args->at(0));
- __ mov(a0, result_register()); // Stub requires parameter in a0 and on tos.
- __ CallStub(&stub);
+ __ CallRuntime(Runtime::kMath_log, 1);
context()->Plug(v0);
}
diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc
index b4d9441..5ac4703 100644
--- a/src/mips/lithium-codegen-mips.cc
+++ b/src/mips/lithium-codegen-mips.cc
@@ -1045,13 +1045,6 @@
CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
break;
}
- case CodeStub::TranscendentalCache: {
- __ lw(a0, MemOperand(sp, 0));
- TranscendentalCacheStub stub(instr->transcendental_type(),
- TranscendentalCacheStub::TAGGED);
- CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
- break;
- }
default:
UNREACHABLE();
}
@@ -1945,7 +1938,7 @@
__ PrepareCallCFunction(0, 2, scratch0());
__ SetCallCDoubleArguments(left, right);
__ CallCFunction(
- ExternalReference::double_fp_operation(Token::MOD, isolate()),
+ ExternalReference::mod_two_doubles_operation(isolate()),
0, 2);
// Move the result in the double result register.
__ GetCFunctionDoubleResult(result);
@@ -3864,13 +3857,11 @@
void LCodeGen::DoMathLog(LMathLog* instr) {
- ASSERT(ToDoubleRegister(instr->result()).is(f4));
- // Set the context register to a GC-safe fake value. Clobbering it is
- // OK because this instruction is marked as a call.
- __ mov(cp, zero_reg);
- TranscendentalCacheStub stub(TranscendentalCache::LOG,
- TranscendentalCacheStub::UNTAGGED);
- CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
+ __ PrepareCallCFunction(0, 1, scratch0());
+ __ SetCallCDoubleArguments(ToDoubleRegister(instr->value()));
+ __ CallCFunction(ExternalReference::math_log_double_function(isolate()),
+ 0, 1);
+ __ GetCFunctionDoubleResult(ToDoubleRegister(instr->result()));
}
diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc
index 1ca008c..155ef63 100644
--- a/src/mips/lithium-mips.cc
+++ b/src/mips/lithium-mips.cc
@@ -1201,9 +1201,10 @@
LInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) {
+ ASSERT(instr->representation().IsDouble());
+ ASSERT(instr->value()->representation().IsDouble());
LOperand* input = UseFixedDouble(instr->value(), f4);
- LMathLog* result = new(zone()) LMathLog(input);
- return MarkAsCall(DefineFixedDouble(result, f4), instr);
+ return MarkAsCall(DefineFixedDouble(new(zone()) LMathLog(input), f4), instr);
}
diff --git a/src/mips/lithium-mips.h b/src/mips/lithium-mips.h
index 99885dc..f0a75c1 100644
--- a/src/mips/lithium-mips.h
+++ b/src/mips/lithium-mips.h
@@ -487,10 +487,6 @@
DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
DECLARE_HYDROGEN_ACCESSOR(CallStub)
-
- TranscendentalCache::Type transcendental_type() {
- return hydrogen()->transcendental_type();
- }
};
diff --git a/src/objects-inl.h b/src/objects-inl.h
index e81d116..d488fc0 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -1297,19 +1297,6 @@
}
-bool JSObject::ShouldTrackAllocationInfo() {
- if (AllocationSite::CanTrack(map()->instance_type())) {
- if (!IsJSArray()) {
- return true;
- }
-
- return AllocationSite::GetMode(GetElementsKind()) ==
- TRACK_ALLOCATION_SITE;
- }
- return false;
-}
-
-
void AllocationSite::Initialize() {
set_transition_info(Smi::FromInt(0));
SetElementsKind(GetInitialFastElementsKind());
diff --git a/src/objects.h b/src/objects.h
index 5a2d559..28de179 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -2117,8 +2117,6 @@
bool HasDictionaryArgumentsElements();
inline SeededNumberDictionary* element_dictionary(); // Gets slow elements.
- inline bool ShouldTrackAllocationInfo();
-
inline void set_map_and_elements(
Map* map,
FixedArrayBase* value,
diff --git a/src/platform-posix.cc b/src/platform-posix.cc
index 0070bdf..02a7b76 100644
--- a/src/platform-posix.cc
+++ b/src/platform-posix.cc
@@ -302,7 +302,6 @@
return (*fast_##name##_function)(x); \
}
-UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG))
UNARY_MATH_FUNCTION(exp, CreateExpFunction())
UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction())
@@ -527,7 +526,6 @@
OS::memcopy_uint8_function =
CreateMemCopyUint8Function(&OS::MemCopyUint8Wrapper);
#endif
- init_fast_log_function();
// fast_exp is initialized lazily.
init_fast_sqrt_function();
}
diff --git a/src/platform-win32.cc b/src/platform-win32.cc
index 7ca5e55..546d31c 100644
--- a/src/platform-win32.cc
+++ b/src/platform-win32.cc
@@ -196,7 +196,6 @@
return (*fast_##name##_function)(x); \
}
-UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG))
UNARY_MATH_FUNCTION(exp, CreateExpFunction())
UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction())
@@ -214,7 +213,6 @@
#ifdef _WIN64
init_modulo_function();
#endif
- init_fast_log_function();
// fast_exp is initialized lazily.
init_fast_sqrt_function();
}
diff --git a/src/platform.h b/src/platform.h
index f94a526..6cf3062 100644
--- a/src/platform.h
+++ b/src/platform.h
@@ -96,7 +96,6 @@
double modulo(double x, double y);
// Custom implementation of math functions.
-double fast_log(double input);
double fast_exp(double input);
double fast_sqrt(double input);
// The custom exp implementation needs 16KB of lookup data; initialize it
diff --git a/src/profile-generator.cc b/src/profile-generator.cc
index acf54da..6bd446e 100644
--- a/src/profile-generator.cc
+++ b/src/profile-generator.cc
@@ -352,9 +352,8 @@
}
-CpuProfile::CpuProfile(const char* title, unsigned uid, bool record_samples)
+CpuProfile::CpuProfile(const char* title, bool record_samples)
: title_(title),
- uid_(uid),
record_samples_(record_samples),
start_time_(Time::NowFromSystemTime()) {
timer_.Start();
@@ -486,9 +485,8 @@
}
-bool CpuProfilesCollection::StartProfiling(const char* title, unsigned uid,
+bool CpuProfilesCollection::StartProfiling(const char* title,
bool record_samples) {
- ASSERT(uid > 0);
current_profiles_semaphore_.Wait();
if (current_profiles_.length() >= kMaxSimultaneousProfiles) {
current_profiles_semaphore_.Signal();
@@ -501,7 +499,7 @@
return false;
}
}
- current_profiles_.Add(new CpuProfile(title, uid, record_samples));
+ current_profiles_.Add(new CpuProfile(title, record_samples));
current_profiles_semaphore_.Signal();
return true;
}
@@ -537,9 +535,8 @@
void CpuProfilesCollection::RemoveProfile(CpuProfile* profile) {
// Called from VM thread for a completed profile.
- unsigned uid = profile->uid();
for (int i = 0; i < finished_profiles_.length(); i++) {
- if (uid == finished_profiles_[i]->uid()) {
+ if (profile == finished_profiles_[i]) {
finished_profiles_.Remove(i);
return;
}
diff --git a/src/profile-generator.h b/src/profile-generator.h
index 6e4758b..81980bf 100644
--- a/src/profile-generator.h
+++ b/src/profile-generator.h
@@ -196,14 +196,13 @@
class CpuProfile {
public:
- CpuProfile(const char* title, unsigned uid, bool record_samples);
+ CpuProfile(const char* title, bool record_samples);
// Add pc -> ... -> main() call path to the profile.
void AddPath(const Vector<CodeEntry*>& path);
void CalculateTotalTicksAndSamplingRate();
const char* title() const { return title_; }
- unsigned uid() const { return uid_; }
const ProfileTree* top_down() const { return &top_down_; }
int samples_count() const { return samples_.length(); }
@@ -218,7 +217,6 @@
private:
const char* title_;
- unsigned uid_;
bool record_samples_;
Time start_time_;
Time end_time_;
@@ -281,7 +279,7 @@
explicit CpuProfilesCollection(Heap* heap);
~CpuProfilesCollection();
- bool StartProfiling(const char* title, unsigned uid, bool record_samples);
+ bool StartProfiling(const char* title, bool record_samples);
CpuProfile* StopProfiling(const char* title);
List<CpuProfile*>* profiles() { return &finished_profiles_; }
const char* GetName(Name* name) {
diff --git a/src/rewriter.cc b/src/rewriter.cc
index ba35284..5e81cf8 100644
--- a/src/rewriter.cc
+++ b/src/rewriter.cc
@@ -207,11 +207,6 @@
}
-void Processor::VisitCaseClause(CaseClause* clause) {
- UNREACHABLE();
-}
-
-
void Processor::VisitContinueStatement(ContinueStatement* node) {
is_set_ = false;
}
diff --git a/src/runtime-profiler.cc b/src/runtime-profiler.cc
index 8c4b11f..390222d 100644
--- a/src/runtime-profiler.cc
+++ b/src/runtime-profiler.cc
@@ -66,7 +66,7 @@
100 * FullCodeGenerator::kCodeSizeMultiplier;
static const int kOSRCodeSizeAllowancePerTick =
- 3 * FullCodeGenerator::kCodeSizeMultiplier;
+ 4 * FullCodeGenerator::kCodeSizeMultiplier;
// Maximum size in bytes of generated code for a function to be optimized
// the very first time it is seen on the stack.
diff --git a/src/runtime.cc b/src/runtime.cc
index 8d84fda..4d84a15 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -7732,7 +7732,7 @@
isolate->counters()->math_log()->Increment();
CONVERT_DOUBLE_ARG_CHECKED(x, 0);
- return isolate->heap()->AllocateHeapNumber(fast_log(x));
+ return isolate->heap()->AllocateHeapNumber(log(x));
}
@@ -9949,8 +9949,7 @@
}
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 @@
// 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 @@
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 @@
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 @@
// 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;
}
diff --git a/src/serialize.cc b/src/serialize.cc
index a0a66f9..5adc2b8 100644
--- a/src/serialize.cc
+++ b/src/serialize.cc
@@ -378,30 +378,10 @@
17,
"Debug::step_in_fp_addr()");
#endif
- Add(ExternalReference::double_fp_operation(Token::ADD, isolate).address(),
- UNCLASSIFIED,
- 18,
- "add_two_doubles");
- Add(ExternalReference::double_fp_operation(Token::SUB, isolate).address(),
- UNCLASSIFIED,
- 19,
- "sub_two_doubles");
- Add(ExternalReference::double_fp_operation(Token::MUL, isolate).address(),
- UNCLASSIFIED,
- 20,
- "mul_two_doubles");
- Add(ExternalReference::double_fp_operation(Token::DIV, isolate).address(),
- UNCLASSIFIED,
- 21,
- "div_two_doubles");
- Add(ExternalReference::double_fp_operation(Token::MOD, isolate).address(),
+ Add(ExternalReference::mod_two_doubles_operation(isolate).address(),
UNCLASSIFIED,
22,
"mod_two_doubles");
- Add(ExternalReference::compare_doubles(isolate).address(),
- UNCLASSIFIED,
- 23,
- "compare_doubles");
#ifndef V8_INTERPRETED_REGEXP
Add(ExternalReference::re_case_insensitive_compare_uc16(isolate).address(),
UNCLASSIFIED,
@@ -429,10 +409,6 @@
UNCLASSIFIED,
29,
"KeyedLookupCache::field_offsets()");
- Add(ExternalReference::transcendental_cache_array_address(isolate).address(),
- UNCLASSIFIED,
- 30,
- "TranscendentalCache::caches()");
Add(ExternalReference::handle_scope_next_address(isolate).address(),
UNCLASSIFIED,
31,
diff --git a/src/type-info.cc b/src/type-info.cc
index eed54ce..73d8c75 100644
--- a/src/type-info.cc
+++ b/src/type-info.cc
@@ -320,18 +320,6 @@
}
-Handle<Type> TypeFeedbackOracle::ClauseType(TypeFeedbackId id) {
- Handle<Object> info = GetInfo(id);
- Handle<Type> result(Type::None(), isolate_);
- if (info->IsCode() && Handle<Code>::cast(info)->is_compare_ic_stub()) {
- Handle<Code> code = Handle<Code>::cast(info);
- CompareIC::State state = ICCompareStub::CompareState(code->stub_info());
- result = CompareIC::StateToType(isolate_, state);
- }
- return result;
-}
-
-
Handle<Type> TypeFeedbackOracle::CountType(TypeFeedbackId id) {
Handle<Object> object = GetInfo(id);
if (!object->IsCode()) return handle(Type::None(), isolate_);
diff --git a/src/type-info.h b/src/type-info.h
index 0ff99e9..8bad5c0 100644
--- a/src/type-info.h
+++ b/src/type-info.h
@@ -303,8 +303,6 @@
Handle<Type> CountType(TypeFeedbackId id);
- Handle<Type> ClauseType(TypeFeedbackId id);
-
Zone* zone() const { return zone_; }
Isolate* isolate() const { return isolate_; }
diff --git a/src/typing.cc b/src/typing.cc
index 9458d6d..de9f404 100644
--- a/src/typing.cc
+++ b/src/typing.cc
@@ -27,6 +27,8 @@
#include "typing.h"
+#include "frames.h"
+#include "frames-inl.h"
#include "parser.h" // for CompileTimeValue; TODO(rossberg): should move
#include "scopes.h"
@@ -68,6 +70,75 @@
#undef RECURSE
+
+Effect AstTyper::ObservedOnStack(Object* value) {
+ Type* lower = Type::OfCurrently(Handle<Object>(value, isolate()));
+ return Effect(Bounds(lower, Type::Any(), isolate()));
+}
+
+
+#ifdef OBJECT_PRINT
+ static void PrintObserved(Variable* var, Object* value, Handle<Type> type) {
+ PrintF(" observed %s ", var->IsParameter() ? "param" : "local");
+ var->name()->Print();
+ PrintF(" : ");
+ value->ShortPrint();
+ PrintF(" -> ");
+ type->TypePrint();
+ }
+#endif // OBJECT_PRINT
+
+
+void AstTyper::ObserveTypesAtOsrEntry(IterationStatement* stmt) {
+ if (stmt->OsrEntryId() != info_->osr_ast_id()) return;
+
+ DisallowHeapAllocation no_gc;
+ JavaScriptFrameIterator it(isolate());
+ JavaScriptFrame* frame = it.frame();
+ Scope* scope = info_->scope();
+
+ // Assert that the frame on the stack belongs to the function we want to OSR.
+ ASSERT_EQ(*info_->closure(), frame->function());
+
+ int params = scope->num_parameters();
+ int locals = scope->StackLocalCount();
+
+ // Use sequential composition to achieve desired narrowing.
+ // The receiver is a parameter with index -1.
+ store_.Seq(parameter_index(-1), ObservedOnStack(frame->receiver()));
+ for (int i = 0; i < params; i++) {
+ store_.Seq(parameter_index(i), ObservedOnStack(frame->GetParameter(i)));
+ }
+
+ for (int i = 0; i < locals; i++) {
+ store_.Seq(stack_local_index(i), ObservedOnStack(frame->GetExpression(i)));
+ }
+
+#ifdef OBJECT_PRINT
+ if (FLAG_trace_osr && FLAG_print_scopes) {
+ PrintObserved(scope->receiver(),
+ frame->receiver(),
+ store_.LookupBounds(parameter_index(-1)).lower);
+
+ for (int i = 0; i < params; i++) {
+ PrintObserved(scope->parameter(i),
+ frame->GetParameter(i),
+ store_.LookupBounds(parameter_index(i)).lower);
+ }
+
+ ZoneList<Variable*> local_vars(locals, zone());
+ ZoneList<Variable*> context_vars(scope->ContextLocalCount(), zone());
+ scope->CollectStackAndContextLocals(&local_vars, &context_vars);
+ for (int i = 0; i < locals; i++) {
+ PrintObserved(local_vars.at(i),
+ frame->GetExpression(i),
+ store_.LookupBounds(stack_local_index(i)).lower);
+ }
+ }
+#endif // OBJECT_PRINT
+}
+
+
#define RECURSE(call) \
do { \
ASSERT(!HasStackOverflow()); \
@@ -151,24 +222,23 @@
RECURSE(Visit(stmt->tag()));
ZoneList<CaseClause*>* clauses = stmt->cases();
- SwitchStatement::SwitchType switch_type = stmt->switch_type();
Effects local_effects(zone());
bool complex_effects = false; // True for label effects or fall-through.
for (int i = 0; i < clauses->length(); ++i) {
CaseClause* clause = clauses->at(i);
+
Effects clause_effects = EnterEffects();
if (!clause->is_default()) {
Expression* label = clause->label();
- SwitchStatement::SwitchType label_switch_type =
- label->IsSmiLiteral() ? SwitchStatement::SMI_SWITCH :
- label->IsStringLiteral() ? SwitchStatement::STRING_SWITCH :
- SwitchStatement::GENERIC_SWITCH;
- if (switch_type == SwitchStatement::UNKNOWN_SWITCH)
- switch_type = label_switch_type;
- else if (switch_type != label_switch_type)
- switch_type = SwitchStatement::GENERIC_SWITCH;
+ // Collect type feedback.
+ Handle<Type> tag_type, label_type, combined_type;
+ oracle()->CompareType(clause->CompareId(),
+ &tag_type, &label_type, &combined_type);
+ NarrowLowerType(stmt->tag(), tag_type);
+ NarrowLowerType(label, label_type);
+ clause->set_compare_type(combined_type);
RECURSE(Visit(label));
if (!clause_effects.IsEmpty()) complex_effects = true;
@@ -189,20 +259,6 @@
} else {
store_.Seq(local_effects);
}
-
- if (switch_type == SwitchStatement::UNKNOWN_SWITCH)
- switch_type = SwitchStatement::GENERIC_SWITCH;
- stmt->set_switch_type(switch_type);
-
- // Collect type feedback.
- // TODO(rossberg): can we eliminate this special case and extra loop?
- if (switch_type == SwitchStatement::SMI_SWITCH) {
- for (int i = 0; i < clauses->length(); ++i) {
- CaseClause* clause = clauses->at(i);
- if (!clause->is_default())
- clause->set_compare_type(oracle()->ClauseType(clause->CompareId()));
- }
- }
}
@@ -221,6 +277,7 @@
// computing the set of variables assigned in only some of the origins of the
// control transfer (such as the loop body here).
store_.Forget(); // Control may transfer here via looping or 'continue'.
+ ObserveTypesAtOsrEntry(stmt);
RECURSE(Visit(stmt->body()));
RECURSE(Visit(stmt->cond()));
store_.Forget(); // Control may transfer here via 'break'.
@@ -235,6 +292,7 @@
store_.Forget(); // Control may transfer here via looping or 'continue'.
RECURSE(Visit(stmt->cond()));
+ ObserveTypesAtOsrEntry(stmt);
RECURSE(Visit(stmt->body()));
store_.Forget(); // Control may transfer here via termination or 'break'.
}
@@ -251,6 +309,7 @@
RECURSE(Visit(stmt->cond()));
}
+ ObserveTypesAtOsrEntry(stmt);
RECURSE(Visit(stmt->body()));
if (stmt->next() != NULL) {
store_.Forget(); // Control may transfer here via 'continue'.
@@ -267,6 +326,7 @@
RECURSE(Visit(stmt->enumerable()));
store_.Forget(); // Control may transfer here via looping or 'continue'.
+ ObserveTypesAtOsrEntry(stmt);
RECURSE(Visit(stmt->body()));
store_.Forget(); // Control may transfer here via 'break'.
}
diff --git a/src/typing.h b/src/typing.h
index a111ae5..ec9132f 100644
--- a/src/typing.h
+++ b/src/typing.h
@@ -58,6 +58,9 @@
private:
explicit AstTyper(CompilationInfo* info);
+ Effect ObservedOnStack(Object* value);
+ void ObserveTypesAtOsrEntry(IterationStatement* stmt);
+
static const int kNoVar = INT_MIN;
typedef v8::internal::Effects<int, kNoVar> Effects;
typedef v8::internal::NestedEffects<int, kNoVar> Store;
@@ -82,12 +85,15 @@
}
void ExitEffects() { store_ = store_.Pop(); }
+ int parameter_index(int index) { return -index - 2; }
+ int stack_local_index(int index) { return index; }
+
int variable_index(Variable* var) {
// Stack locals have the range [0 .. l]
// Parameters have the range [-1 .. p]
// We map this to [-p-2 .. -1, 0 .. l]
- return var->IsStackLocal() ? var->index() :
- var->IsParameter() ? -var->index() - 2 : kNoVar;
+ return var->IsStackLocal() ? stack_local_index(var->index()) :
+ var->IsParameter() ? parameter_index(var->index()) : kNoVar;
}
void VisitDeclarations(ZoneList<Declaration*>* declarations);
diff --git a/src/utils.h b/src/utils.h
index 3a0936e..14a4c56 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -1118,6 +1118,7 @@
bool IsNone() const { return id_ == kNoneId; }
bool operator==(const BailoutId& other) const { return id_ == other.id_; }
+ bool operator!=(const BailoutId& other) const { return id_ != other.id_; }
private:
static const int kNoneId = -1;
diff --git a/src/v8-counters.h b/src/v8-counters.h
index 72f5650..0bd4955 100644
--- a/src/v8-counters.h
+++ b/src/v8-counters.h
@@ -248,8 +248,6 @@
SC(math_pow, V8.MathPow) \
SC(math_round, V8.MathRound) \
SC(math_sqrt, V8.MathSqrt) \
- SC(transcendental_cache_hit, V8.TranscendentalCacheHit) \
- SC(transcendental_cache_miss, V8.TranscendentalCacheMiss) \
SC(stack_interrupts, V8.StackInterrupts) \
SC(runtime_profiler_ticks, V8.RuntimeProfilerTicks) \
SC(bounds_checks_eliminated, V8.BoundsChecksEliminated) \
diff --git a/src/version.cc b/src/version.cc
index 99b44d3..1a8f1c0 100644
--- a/src/version.cc
+++ b/src/version.cc
@@ -34,7 +34,7 @@
// system so their names cannot be changed without changing the scripts.
#define MAJOR_VERSION 3
#define MINOR_VERSION 24
-#define BUILD_NUMBER 3
+#define BUILD_NUMBER 4
#define PATCH_LEVEL 0
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc
index d04e976..5b5212c 100644
--- a/src/x64/code-stubs-x64.cc
+++ b/src/x64/code-stubs-x64.cc
@@ -597,220 +597,6 @@
}
-void TranscendentalCacheStub::Generate(MacroAssembler* masm) {
- // TAGGED case:
- // Input:
- // rsp[8] : argument (should be number).
- // rsp[0] : return address.
- // Output:
- // rax: tagged double result.
- // UNTAGGED case:
- // Input::
- // rsp[0] : return address.
- // xmm1 : untagged double input argument
- // Output:
- // xmm1 : untagged double result.
-
- Label runtime_call;
- Label runtime_call_clear_stack;
- Label skip_cache;
- const bool tagged = (argument_type_ == TAGGED);
- if (tagged) {
- Label input_not_smi, loaded;
-
- // Test that rax is a number.
- StackArgumentsAccessor args(rsp, 1, ARGUMENTS_DONT_CONTAIN_RECEIVER);
- __ movq(rax, args.GetArgumentOperand(0));
- __ JumpIfNotSmi(rax, &input_not_smi, Label::kNear);
- // Input is a smi. Untag and load it onto the FPU stack.
- // Then load the bits of the double into rbx.
- __ SmiToInteger32(rax, rax);
- __ subq(rsp, Immediate(kDoubleSize));
- __ Cvtlsi2sd(xmm1, rax);
- __ movsd(Operand(rsp, 0), xmm1);
- __ movq(rbx, xmm1);
- __ movq(rdx, xmm1);
- __ fld_d(Operand(rsp, 0));
- __ addq(rsp, Immediate(kDoubleSize));
- __ jmp(&loaded, Label::kNear);
-
- __ bind(&input_not_smi);
- // Check if input is a HeapNumber.
- __ LoadRoot(rbx, Heap::kHeapNumberMapRootIndex);
- __ cmpq(rbx, FieldOperand(rax, HeapObject::kMapOffset));
- __ j(not_equal, &runtime_call);
- // Input is a HeapNumber. Push it on the FPU stack and load its
- // bits into rbx.
- __ fld_d(FieldOperand(rax, HeapNumber::kValueOffset));
- __ MoveDouble(rbx, FieldOperand(rax, HeapNumber::kValueOffset));
- __ movq(rdx, rbx);
-
- __ bind(&loaded);
- } else { // UNTAGGED.
- __ movq(rbx, xmm1);
- __ movq(rdx, xmm1);
- }
-
- // ST[0] == double value, if TAGGED.
- // rbx = bits of double value.
- // rdx = also bits of double value.
- // Compute hash (h is 32 bits, bits are 64 and the shifts are arithmetic):
- // h = h0 = bits ^ (bits >> 32);
- // h ^= h >> 16;
- // h ^= h >> 8;
- // h = h & (cacheSize - 1);
- // or h = (h0 ^ (h0 >> 8) ^ (h0 >> 16) ^ (h0 >> 24)) & (cacheSize - 1)
- __ sar(rdx, Immediate(32));
- __ xorl(rdx, rbx);
- __ movl(rcx, rdx);
- __ movl(rax, rdx);
- __ movl(rdi, rdx);
- __ sarl(rdx, Immediate(8));
- __ sarl(rcx, Immediate(16));
- __ sarl(rax, Immediate(24));
- __ xorl(rcx, rdx);
- __ xorl(rax, rdi);
- __ xorl(rcx, rax);
- ASSERT(IsPowerOf2(TranscendentalCache::SubCache::kCacheSize));
- __ andl(rcx, Immediate(TranscendentalCache::SubCache::kCacheSize - 1));
-
- // ST[0] == double value.
- // rbx = bits of double value.
- // rcx = TranscendentalCache::hash(double value).
- ExternalReference cache_array =
- ExternalReference::transcendental_cache_array_address(masm->isolate());
- __ Move(rax, cache_array);
- int cache_array_index =
- type_ * sizeof(masm->isolate()->transcendental_cache()->caches_[0]);
- __ movq(rax, Operand(rax, cache_array_index));
- // rax points to the cache for the type type_.
- // If NULL, the cache hasn't been initialized yet, so go through runtime.
- __ testq(rax, rax);
- __ j(zero, &runtime_call_clear_stack); // Only clears stack if TAGGED.
-#ifdef DEBUG
- // Check that the layout of cache elements match expectations.
- { // NOLINT - doesn't like a single brace on a line.
- TranscendentalCache::SubCache::Element test_elem[2];
- char* elem_start = reinterpret_cast<char*>(&test_elem[0]);
- char* elem2_start = reinterpret_cast<char*>(&test_elem[1]);
- char* elem_in0 = reinterpret_cast<char*>(&(test_elem[0].in[0]));
- char* elem_in1 = reinterpret_cast<char*>(&(test_elem[0].in[1]));
- char* elem_out = reinterpret_cast<char*>(&(test_elem[0].output));
- // Two uint_32's and a pointer per element.
- CHECK_EQ(2 * kIntSize + 1 * kPointerSize,
- static_cast<int>(elem2_start - elem_start));
- CHECK_EQ(0, static_cast<int>(elem_in0 - elem_start));
- CHECK_EQ(kIntSize, static_cast<int>(elem_in1 - elem_start));
- CHECK_EQ(2 * kIntSize, static_cast<int>(elem_out - elem_start));
- }
-#endif
- // Find the address of the rcx'th entry in the cache, i.e., &rax[rcx*16].
- __ addl(rcx, rcx);
- __ lea(rcx, Operand(rax, rcx, times_8, 0));
- // Check if cache matches: Double value is stored in uint32_t[2] array.
- Label cache_miss;
- __ cmpq(rbx, Operand(rcx, 0));
- __ j(not_equal, &cache_miss, Label::kNear);
- // Cache hit!
- Counters* counters = masm->isolate()->counters();
- __ IncrementCounter(counters->transcendental_cache_hit(), 1);
- __ movq(rax, Operand(rcx, 2 * kIntSize));
- if (tagged) {
- __ fstp(0); // Clear FPU stack.
- __ ret(kPointerSize);
- } else { // UNTAGGED.
- __ movsd(xmm1, FieldOperand(rax, HeapNumber::kValueOffset));
- __ Ret();
- }
-
- __ bind(&cache_miss);
- __ IncrementCounter(counters->transcendental_cache_miss(), 1);
- // Update cache with new value.
- if (tagged) {
- __ AllocateHeapNumber(rax, rdi, &runtime_call_clear_stack);
- } else { // UNTAGGED.
- __ AllocateHeapNumber(rax, rdi, &skip_cache);
- __ movsd(FieldOperand(rax, HeapNumber::kValueOffset), xmm1);
- __ fld_d(FieldOperand(rax, HeapNumber::kValueOffset));
- }
- GenerateOperation(masm, type_);
- __ movq(Operand(rcx, 0), rbx);
- __ movq(Operand(rcx, 2 * kIntSize), rax);
- __ fstp_d(FieldOperand(rax, HeapNumber::kValueOffset));
- if (tagged) {
- __ ret(kPointerSize);
- } else { // UNTAGGED.
- __ movsd(xmm1, FieldOperand(rax, HeapNumber::kValueOffset));
- __ Ret();
-
- // Skip cache and return answer directly, only in untagged case.
- __ bind(&skip_cache);
- __ subq(rsp, Immediate(kDoubleSize));
- __ movsd(Operand(rsp, 0), xmm1);
- __ fld_d(Operand(rsp, 0));
- GenerateOperation(masm, type_);
- __ fstp_d(Operand(rsp, 0));
- __ movsd(xmm1, Operand(rsp, 0));
- __ addq(rsp, Immediate(kDoubleSize));
- // We return the value in xmm1 without adding it to the cache, but
- // we cause a scavenging GC so that future allocations will succeed.
- {
- FrameScope scope(masm, StackFrame::INTERNAL);
- // Allocate an unused object bigger than a HeapNumber.
- __ Push(Smi::FromInt(2 * kDoubleSize));
- __ CallRuntimeSaveDoubles(Runtime::kAllocateInNewSpace);
- }
- __ Ret();
- }
-
- // Call runtime, doing whatever allocation and cleanup is necessary.
- if (tagged) {
- __ bind(&runtime_call_clear_stack);
- __ fstp(0);
- __ bind(&runtime_call);
- __ TailCallExternalReference(
- ExternalReference(RuntimeFunction(), masm->isolate()), 1, 1);
- } else { // UNTAGGED.
- __ bind(&runtime_call_clear_stack);
- __ bind(&runtime_call);
- __ AllocateHeapNumber(rax, rdi, &skip_cache);
- __ movsd(FieldOperand(rax, HeapNumber::kValueOffset), xmm1);
- {
- FrameScope scope(masm, StackFrame::INTERNAL);
- __ push(rax);
- __ CallRuntime(RuntimeFunction(), 1);
- }
- __ movsd(xmm1, FieldOperand(rax, HeapNumber::kValueOffset));
- __ Ret();
- }
-}
-
-
-Runtime::FunctionId TranscendentalCacheStub::RuntimeFunction() {
- switch (type_) {
- // Add more cases when necessary.
- case TranscendentalCache::LOG: return Runtime::kMath_log;
- default:
- UNIMPLEMENTED();
- return Runtime::kAbort;
- }
-}
-
-
-void TranscendentalCacheStub::GenerateOperation(
- MacroAssembler* masm, TranscendentalCache::Type type) {
- // Registers:
- // rax: Newly allocated HeapNumber, which must be preserved.
- // rbx: Bits of input double. Must be preserved.
- // rcx: Pointer to cache entry. Must be preserved.
- // st(0): Input double
- ASSERT(type == TranscendentalCache::LOG);
- __ fldln2();
- __ fxch();
- __ fyl2x();
-}
-
-
void FloatingPointHelper::LoadSSE2UnknownOperands(MacroAssembler* masm,
Label* not_numbers) {
Label load_smi_rdx, load_nonsmi_rax, load_smi_rax, load_float_rax, done;
diff --git a/src/x64/code-stubs-x64.h b/src/x64/code-stubs-x64.h
index 7a3f6a6..3c5666e 100644
--- a/src/x64/code-stubs-x64.h
+++ b/src/x64/code-stubs-x64.h
@@ -37,31 +37,6 @@
void ArrayNativeCode(MacroAssembler* masm, Label* call_generic_code);
-// Compute a transcendental math function natively, or call the
-// TranscendentalCache runtime function.
-class TranscendentalCacheStub: public PlatformCodeStub {
- public:
- enum ArgumentType {
- TAGGED = 0,
- UNTAGGED = 1 << TranscendentalCache::kTranscendentalTypeBits
- };
-
- explicit TranscendentalCacheStub(TranscendentalCache::Type type,
- ArgumentType argument_type)
- : type_(type), argument_type_(argument_type) {}
- void Generate(MacroAssembler* masm);
- static void GenerateOperation(MacroAssembler* masm,
- TranscendentalCache::Type type);
- private:
- TranscendentalCache::Type type_;
- ArgumentType argument_type_;
-
- Major MajorKey() { return TranscendentalCache; }
- int MinorKey() { return type_ | argument_type_; }
- Runtime::FunctionId RuntimeFunction();
-};
-
-
class StoreBufferOverflowStub: public PlatformCodeStub {
public:
explicit StoreBufferOverflowStub(SaveFPRegsMode save_fp)
diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc
index 96d930e..d224e60 100644
--- a/src/x64/codegen-x64.cc
+++ b/src/x64/codegen-x64.cc
@@ -55,47 +55,6 @@
#define __ masm.
-UnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type) {
- size_t actual_size;
- // Allocate buffer in executable space.
- byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB,
- &actual_size,
- true));
- if (buffer == NULL) {
- // Fallback to library function if function cannot be created.
- switch (type) {
- case TranscendentalCache::LOG: return &log;
- default: UNIMPLEMENTED();
- }
- }
-
- MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
- // xmm0: raw double input.
- // Move double input into registers.
- __ push(rbx);
- __ push(rdi);
- __ movq(rbx, xmm0);
- __ push(rbx);
- __ fld_d(Operand(rsp, 0));
- TranscendentalCacheStub::GenerateOperation(&masm, type);
- // The return value is expected to be in xmm0.
- __ fstp_d(Operand(rsp, 0));
- __ pop(rbx);
- __ movq(xmm0, rbx);
- __ pop(rdi);
- __ pop(rbx);
- __ Ret();
-
- CodeDesc desc;
- masm.GetCode(&desc);
- ASSERT(!RelocInfo::RequiresRelocation(desc));
-
- CPU::FlushICache(buffer, actual_size);
- OS::ProtectCode(buffer, actual_size);
- return FUNCTION_CAST<UnaryMathFunction>(buffer);
-}
-
-
UnaryMathFunction CreateExpFunction() {
if (!FLAG_fast_math) return &exp;
size_t actual_size;
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
index 473f548..a56f223 100644
--- a/src/x64/full-codegen-x64.cc
+++ b/src/x64/full-codegen-x64.cc
@@ -986,6 +986,15 @@
CallIC(ic, RelocInfo::CODE_TARGET, clause->CompareId());
patch_site.EmitPatchInfo();
+ Label skip;
+ __ jmp(&skip, Label::kNear);
+ PrepareForBailout(clause, TOS_REG);
+ __ CompareRoot(rax, Heap::kTrueValueRootIndex);
+ __ j(not_equal, &next_test);
+ __ Drop(1);
+ __ jmp(clause->body_target());
+ __ bind(&skip);
+
__ testq(rax, rax);
__ j(not_equal, &next_test);
__ Drop(1); // Switch value is no longer needed.
@@ -3628,13 +3637,11 @@
void FullCodeGenerator::EmitMathLog(CallRuntime* expr) {
- // Load the argument on the stack and call the stub.
- TranscendentalCacheStub stub(TranscendentalCache::LOG,
- TranscendentalCacheStub::TAGGED);
+ // Load the argument on the stack and call the runtime function.
ZoneList<Expression*>* args = expr->arguments();
ASSERT(args->length() == 1);
VisitForStackValue(args->at(0));
- __ CallStub(&stub);
+ __ CallRuntime(Runtime::kMath_log, 1);
context()->Plug(rax);
}
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
index c6d5a14..c392b45 100644
--- a/src/x64/lithium-codegen-x64.cc
+++ b/src/x64/lithium-codegen-x64.cc
@@ -968,12 +968,6 @@
CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
break;
}
- case CodeStub::TranscendentalCache: {
- TranscendentalCacheStub stub(instr->transcendental_type(),
- TranscendentalCacheStub::TAGGED);
- CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
- break;
- }
default:
UNREACHABLE();
}
@@ -1904,7 +1898,7 @@
__ movaps(xmm_scratch, left);
ASSERT(right.is(xmm1));
__ CallCFunction(
- ExternalReference::double_fp_operation(Token::MOD, isolate()), 2);
+ ExternalReference::mod_two_doubles_operation(isolate()), 2);
__ movaps(result, xmm_scratch);
break;
}
@@ -3732,7 +3726,7 @@
__ xorps(xmm_scratch, xmm_scratch);
__ ucomisd(input_reg, xmm_scratch);
__ j(above, &positive, Label::kNear);
- __ j(equal, &zero, Label::kNear);
+ __ j(not_carry, &zero, Label::kNear);
ExternalReference nan =
ExternalReference::address_of_canonical_non_hole_nan();
Operand nan_operand = masm()->ExternalOperand(nan);
diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc
index 974a970..480adf8 100644
--- a/src/x64/lithium-x64.cc
+++ b/src/x64/lithium-x64.cc
@@ -1223,8 +1223,7 @@
ASSERT(instr->representation().IsDouble());
ASSERT(instr->value()->representation().IsDouble());
LOperand* input = UseRegisterAtStart(instr->value());
- LMathLog* result = new(zone()) LMathLog(input);
- return DefineSameAsFirst(result);
+ return MarkAsCall(DefineSameAsFirst(new(zone()) LMathLog(input)), instr);
}
diff --git a/src/x64/lithium-x64.h b/src/x64/lithium-x64.h
index e644c2d..7ba1d30 100644
--- a/src/x64/lithium-x64.h
+++ b/src/x64/lithium-x64.h
@@ -489,10 +489,6 @@
DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
DECLARE_HYDROGEN_ACCESSOR(CallStub)
-
- TranscendentalCache::Type transcendental_type() {
- return hydrogen()->transcendental_type();
- }
};
diff --git a/test/cctest/cctest.gyp b/test/cctest/cctest.gyp
index 2017d61..af1183f 100644
--- a/test/cctest/cctest.gyp
+++ b/test/cctest/cctest.gyp
@@ -47,6 +47,7 @@
'gay-fixed.cc',
'gay-precision.cc',
'gay-shortest.cc',
+ 'profiler-extension.cc',
'test-accessors.cc',
'test-alloc.cc',
'test-api.cc',
diff --git a/test/cctest/profiler-extension.cc b/test/cctest/profiler-extension.cc
new file mode 100644
index 0000000..7b0b099
--- /dev/null
+++ b/test/cctest/profiler-extension.cc
@@ -0,0 +1,72 @@
+// Copyright 2013 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Tests of profiles generator and utilities.
+
+#include "profiler-extension.h"
+
+#include "cctest.h"
+
+const v8::CpuProfile* ProfilerExtension::last_profile = NULL;
+const char* ProfilerExtension::kSource =
+ "native function startProfiling();"
+ "native function stopProfiling();";
+
+v8::Handle<v8::FunctionTemplate> ProfilerExtension::GetNativeFunctionTemplate(
+ v8::Isolate* isolate, v8::Handle<v8::String> name) {
+ if (name->Equals(v8::String::NewFromUtf8(isolate, "startProfiling"))) {
+ return v8::FunctionTemplate::New(ProfilerExtension::StartProfiling);
+ } else if (name->Equals(v8::String::NewFromUtf8(isolate, "stopProfiling"))) {
+ return v8::FunctionTemplate::New(ProfilerExtension::StopProfiling);
+ } else {
+ CHECK(false);
+ return v8::Handle<v8::FunctionTemplate>();
+ }
+}
+
+
+void ProfilerExtension::StartProfiling(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ last_profile = NULL;
+ v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler();
+ cpu_profiler->StartCpuProfiling((args.Length() > 0)
+ ? args[0].As<v8::String>()
+ : v8::String::Empty(args.GetIsolate()));
+}
+
+
+void ProfilerExtension::StopProfiling(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler();
+ last_profile = cpu_profiler->StopCpuProfiling((args.Length() > 0)
+ ? args[0].As<v8::String>()
+ : v8::String::Empty(args.GetIsolate()));
+}
+
+
+static ProfilerExtension kProfilerExtension;
+v8::DeclareExtension kProfilerExtensionDeclaration(&kProfilerExtension);
diff --git a/test/cctest/profiler-extension.h b/test/cctest/profiler-extension.h
new file mode 100644
index 0000000..00960b9
--- /dev/null
+++ b/test/cctest/profiler-extension.h
@@ -0,0 +1,43 @@
+// Copyright 2013 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Tests of profiles generator and utilities.
+
+#include "../include/v8-profiler.h"
+
+class ProfilerExtension : public v8::Extension {
+ public:
+ ProfilerExtension() : v8::Extension("v8/profiler", kSource) { }
+ virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate(
+ v8::Isolate* isolate,
+ v8::Handle<v8::String> name);
+ static void StartProfiling(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void StopProfiling(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static const v8::CpuProfile* last_profile;
+ private:
+ static const char* kSource;
+};
diff --git a/test/cctest/test-accessors.cc b/test/cctest/test-accessors.cc
index 2c257ee..ba71600 100644
--- a/test/cctest/test-accessors.cc
+++ b/test/cctest/test-accessors.cc
@@ -65,11 +65,12 @@
THREADED_TEST(PropertyHandler) {
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
- Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+ Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate);
fun_templ->InstanceTemplate()->SetAccessor(v8_str("foo"), handle_property);
Local<v8::FunctionTemplate> getter_templ =
- v8::FunctionTemplate::New(handle_property);
+ v8::FunctionTemplate::New(isolate, handle_property);
getter_templ->SetLength(0);
fun_templ->
InstanceTemplate()->SetAccessorProperty(v8_str("bar"), getter_templ);
@@ -120,17 +121,18 @@
foo = 0;
bar = -4;
baz = 10;
- v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
templ->InstanceTemplate()->SetAccessor(
v8_str("foo"), GetIntValue, SetIntValue,
- v8::External::New(CcTest::isolate(), &foo));
+ v8::External::New(isolate, &foo));
templ->InstanceTemplate()->SetAccessor(
v8_str("bar"), GetIntValue, SetIntValue,
- v8::External::New(CcTest::isolate(), &bar));
+ v8::External::New(isolate, &bar));
templ->InstanceTemplate()->SetAccessor(
v8_str("baz"), GetIntValue, SetIntValue,
- v8::External::New(CcTest::isolate(), &baz));
+ v8::External::New(isolate, &baz));
LocalContext env(0, templ->InstanceTemplate());
v8_compile("foo = (++bar) + baz")->Run();
CHECK_EQ(bar, -3);
@@ -190,12 +192,13 @@
THREADED_TEST(AccessorIC) {
LocalContext context;
- v8::HandleScope scope(context->GetIsolate());
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope scope(isolate);
v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
obj->SetAccessor(v8_str("x0"), XGetter, XSetter);
obj->SetAccessorProperty(v8_str("x1"),
- v8::FunctionTemplate::New(XGetter),
- v8::FunctionTemplate::New(XSetter));
+ v8::FunctionTemplate::New(isolate, XGetter),
+ v8::FunctionTemplate::New(isolate, XSetter));
x_holder = obj->NewInstance();
context->Global()->Set(v8_str("holder"), x_holder);
x_receiver = v8::Object::New();
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 91f3736..9ea8b0d 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -94,7 +94,7 @@
cpu_profiler->StartCpuProfiling(profile_name);
(*test)();
- cpu_profiler->DeleteAllCpuProfiles();
+ reinterpret_cast<i::CpuProfiler*>(cpu_profiler)->DeleteAllProfiles();
}
@@ -252,18 +252,20 @@
THREADED_TEST(ReceiverSignature) {
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
// Setup templates.
- v8::Handle<v8::FunctionTemplate> fun = v8::FunctionTemplate::New();
- v8::Handle<v8::Signature> sig = v8::Signature::New(env->GetIsolate(), fun);
+ v8::Handle<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(isolate);
+ v8::Handle<v8::Signature> sig = v8::Signature::New(isolate, fun);
v8::Handle<v8::FunctionTemplate> callback_sig =
v8::FunctionTemplate::New(
- IncrementingSignatureCallback, Local<Value>(), sig);
+ isolate, IncrementingSignatureCallback, Local<Value>(), sig);
v8::Handle<v8::FunctionTemplate> callback =
- v8::FunctionTemplate::New(IncrementingSignatureCallback);
- v8::Handle<v8::FunctionTemplate> sub_fun = v8::FunctionTemplate::New();
+ v8::FunctionTemplate::New(isolate, IncrementingSignatureCallback);
+ v8::Handle<v8::FunctionTemplate> sub_fun = v8::FunctionTemplate::New(isolate);
sub_fun->Inherit(fun);
- v8::Handle<v8::FunctionTemplate> unrel_fun = v8::FunctionTemplate::New();
+ v8::Handle<v8::FunctionTemplate> unrel_fun =
+ v8::FunctionTemplate::New(isolate);
// Install properties.
v8::Handle<v8::ObjectTemplate> fun_proto = fun->PrototypeTemplate();
fun_proto->Set(v8_str("prop_sig"), callback_sig);
@@ -325,13 +327,17 @@
THREADED_TEST(ArgumentSignature) {
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
- v8::Handle<v8::FunctionTemplate> cons = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::FunctionTemplate> cons = v8::FunctionTemplate::New(isolate);
cons->SetClassName(v8_str("Cons"));
v8::Handle<v8::Signature> sig = v8::Signature::New(
- env->GetIsolate(), v8::Handle<v8::FunctionTemplate>(), 1, &cons);
+ isolate, v8::Handle<v8::FunctionTemplate>(), 1, &cons);
v8::Handle<v8::FunctionTemplate> fun =
- v8::FunctionTemplate::New(SignatureCallback, v8::Handle<Value>(), sig);
+ v8::FunctionTemplate::New(isolate,
+ SignatureCallback,
+ v8::Handle<Value>(),
+ sig);
env->Global()->Set(v8_str("Cons"), cons->GetFunction());
env->Global()->Set(v8_str("Fun1"), fun->GetFunction());
@@ -344,18 +350,21 @@
v8::Handle<Value> value3 = CompileRun("Fun1() == '';");
CHECK(value3->IsTrue());
- v8::Handle<v8::FunctionTemplate> cons1 = v8::FunctionTemplate::New();
+ v8::Handle<v8::FunctionTemplate> cons1 = v8::FunctionTemplate::New(isolate);
cons1->SetClassName(v8_str("Cons1"));
- v8::Handle<v8::FunctionTemplate> cons2 = v8::FunctionTemplate::New();
+ v8::Handle<v8::FunctionTemplate> cons2 = v8::FunctionTemplate::New(isolate);
cons2->SetClassName(v8_str("Cons2"));
- v8::Handle<v8::FunctionTemplate> cons3 = v8::FunctionTemplate::New();
+ v8::Handle<v8::FunctionTemplate> cons3 = v8::FunctionTemplate::New(isolate);
cons3->SetClassName(v8_str("Cons3"));
v8::Handle<v8::FunctionTemplate> args[3] = { cons1, cons2, cons3 };
v8::Handle<v8::Signature> wsig = v8::Signature::New(
- env->GetIsolate(), v8::Handle<v8::FunctionTemplate>(), 3, args);
+ isolate, v8::Handle<v8::FunctionTemplate>(), 3, args);
v8::Handle<v8::FunctionTemplate> fun2 =
- v8::FunctionTemplate::New(SignatureCallback, v8::Handle<Value>(), wsig);
+ v8::FunctionTemplate::New(isolate,
+ SignatureCallback,
+ v8::Handle<Value>(),
+ wsig);
env->Global()->Set(v8_str("Cons1"), cons1->GetFunction());
env->Global()->Set(v8_str("Cons2"), cons2->GetFunction());
@@ -1020,10 +1029,11 @@
// Test constructor calls.
{
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
Local<v8::FunctionTemplate> fun_templ =
- v8::FunctionTemplate::New(handler);
+ v8::FunctionTemplate::New(isolate, handler);
Local<Function> fun = fun_templ->GetFunction();
env->Global()->Set(v8_str("obj"), fun);
Local<Script> script = v8_compile("obj()");
@@ -1035,9 +1045,10 @@
// the previous one.
{
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
- Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate);
fun_templ->SetCallHandler(handler_2);
Local<Function> fun = fun_templ->GetFunction();
env->Global()->Set(v8_str("obj"), fun);
@@ -1056,7 +1067,7 @@
v8::HandleScope scope(env->GetIsolate());
Local<v8::FunctionTemplate> fun_templ =
- v8::FunctionTemplate::New(constructor);
+ v8::FunctionTemplate::New(env->GetIsolate(), constructor);
fun_templ->SetClassName(v8_str("funky"));
fun_templ->InstanceTemplate()->SetAccessor(v8_str("m"), accessor);
Local<Function> fun = fun_templ->GetFunction();
@@ -1096,7 +1107,7 @@
v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New();
object_template->Set(env->GetIsolate(), "callback",
- v8::FunctionTemplate::New(callback));
+ v8::FunctionTemplate::New(env->GetIsolate(), callback));
v8::Local<v8::Object> object = object_template->NewInstance();
(*env)->Global()->Set(v8_str("callback_object"), object);
v8::Handle<v8::Script> script;
@@ -1199,7 +1210,7 @@
v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New();
v8::FunctionCallback callback = &FastReturnValueCallback<T>;
object_template->Set(env->GetIsolate(), "callback",
- v8::FunctionTemplate::New(callback));
+ v8::FunctionTemplate::New(env->GetIsolate(), callback));
v8::Local<v8::Object> object = object_template->NewInstance();
(*env)->Global()->Set(v8_str("callback_object"), object);
return scope.Escape(CompileRun("callback_object.callback()"));
@@ -1275,10 +1286,15 @@
THREADED_TEST(FunctionTemplateSetLength) {
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
{
- Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(
- handle_callback, Handle<v8::Value>(), Handle<v8::Signature>(), 23);
+ Local<v8::FunctionTemplate> fun_templ =
+ v8::FunctionTemplate::New(isolate,
+ handle_callback,
+ Handle<v8::Value>(),
+ Handle<v8::Signature>(),
+ 23);
Local<Function> fun = fun_templ->GetFunction();
env->Global()->Set(v8_str("obj"), fun);
Local<Script> script = v8_compile("obj.length");
@@ -1286,7 +1302,7 @@
}
{
Local<v8::FunctionTemplate> fun_templ =
- v8::FunctionTemplate::New(handle_callback);
+ v8::FunctionTemplate::New(isolate, handle_callback);
fun_templ->SetLength(22);
Local<Function> fun = fun_templ->GetFunction();
env->Global()->Set(v8_str("obj"), fun);
@@ -1296,7 +1312,7 @@
{
// Without setting length it defaults to 0.
Local<v8::FunctionTemplate> fun_templ =
- v8::FunctionTemplate::New(handle_callback);
+ v8::FunctionTemplate::New(isolate, handle_callback);
Local<Function> fun = fun_templ->GetFunction();
env->Global()->Set(v8_str("obj"), fun);
Local<Script> script = v8_compile("obj.length");
@@ -1315,14 +1331,15 @@
static void TestExternalPointerWrapping() {
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
v8::Handle<v8::Value> data =
- v8::External::New(env->GetIsolate(), expected_ptr);
+ v8::External::New(isolate, expected_ptr);
v8::Handle<v8::Object> obj = v8::Object::New();
obj->Set(v8_str("func"),
- v8::FunctionTemplate::New(callback, data)->GetFunction());
+ v8::FunctionTemplate::New(isolate, callback, data)->GetFunction());
env->Global()->Set(v8_str("obj"), obj);
CHECK(CompileRun(
@@ -1381,11 +1398,12 @@
THREADED_TEST(FindInstanceInPrototypeChain) {
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
- Local<v8::FunctionTemplate> base = v8::FunctionTemplate::New();
- Local<v8::FunctionTemplate> derived = v8::FunctionTemplate::New();
- Local<v8::FunctionTemplate> other = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> base = v8::FunctionTemplate::New(isolate);
+ Local<v8::FunctionTemplate> derived = v8::FunctionTemplate::New(isolate);
+ Local<v8::FunctionTemplate> other = v8::FunctionTemplate::New(isolate);
derived->Inherit(base);
Local<v8::Function> base_function = base->GetFunction();
@@ -1756,12 +1774,14 @@
THREADED_TEST(GlobalPrototype) {
- v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::FunctionTemplate> func_templ =
+ v8::FunctionTemplate::New(isolate);
func_templ->PrototypeTemplate()->Set(
- CcTest::isolate(), "dummy", v8::FunctionTemplate::New(DummyCallHandler));
+ isolate, "dummy", v8::FunctionTemplate::New(isolate, DummyCallHandler));
v8::Handle<ObjectTemplate> templ = func_templ->InstanceTemplate();
- templ->Set(CcTest::isolate(), "x", v8_num(200));
+ templ->Set(isolate, "x", v8_num(200));
templ->SetAccessor(v8_str("m"), GetM);
LocalContext env(0, templ);
v8::Handle<Script> script(v8_compile("dummy()"));
@@ -1773,20 +1793,21 @@
THREADED_TEST(ObjectTemplate) {
- v8::HandleScope scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
Local<ObjectTemplate> templ1 = ObjectTemplate::New();
- templ1->Set(CcTest::isolate(), "x", v8_num(10));
- templ1->Set(CcTest::isolate(), "y", v8_num(13));
+ templ1->Set(isolate, "x", v8_num(10));
+ templ1->Set(isolate, "y", v8_num(13));
LocalContext env;
Local<v8::Object> instance1 = templ1->NewInstance();
env->Global()->Set(v8_str("p"), instance1);
CHECK(v8_compile("(p.x == 10)")->Run()->BooleanValue());
CHECK(v8_compile("(p.y == 13)")->Run()->BooleanValue());
- Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New();
- fun->PrototypeTemplate()->Set(CcTest::isolate(), "nirk", v8_num(123));
+ Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(isolate);
+ fun->PrototypeTemplate()->Set(isolate, "nirk", v8_num(123));
Local<ObjectTemplate> templ2 = fun->InstanceTemplate();
- templ2->Set(CcTest::isolate(), "a", v8_num(12));
- templ2->Set(CcTest::isolate(), "b", templ1);
+ templ2->Set(isolate, "a", v8_num(12));
+ templ2->Set(isolate, "b", templ1);
Local<v8::Object> instance2 = templ2->NewInstance();
env->Global()->Set(v8_str("q"), instance2);
CHECK(v8_compile("(q.nirk == 123)")->Run()->BooleanValue());
@@ -1810,21 +1831,23 @@
THREADED_TEST(DescriptorInheritance) {
- v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::FunctionTemplate> super = v8::FunctionTemplate::New();
- super->PrototypeTemplate()->Set(CcTest::isolate(), "flabby",
- v8::FunctionTemplate::New(GetFlabby));
- super->PrototypeTemplate()->Set(CcTest::isolate(), "PI", v8_num(3.14));
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::FunctionTemplate> super = v8::FunctionTemplate::New(isolate);
+ super->PrototypeTemplate()->Set(isolate, "flabby",
+ v8::FunctionTemplate::New(isolate,
+ GetFlabby));
+ super->PrototypeTemplate()->Set(isolate, "PI", v8_num(3.14));
super->InstanceTemplate()->SetAccessor(v8_str("knurd"), GetKnurd);
- v8::Handle<v8::FunctionTemplate> base1 = v8::FunctionTemplate::New();
+ v8::Handle<v8::FunctionTemplate> base1 = v8::FunctionTemplate::New(isolate);
base1->Inherit(super);
- base1->PrototypeTemplate()->Set(CcTest::isolate(), "v1", v8_num(20.1));
+ base1->PrototypeTemplate()->Set(isolate, "v1", v8_num(20.1));
- v8::Handle<v8::FunctionTemplate> base2 = v8::FunctionTemplate::New();
+ v8::Handle<v8::FunctionTemplate> base2 = v8::FunctionTemplate::New(isolate);
base2->Inherit(super);
- base2->PrototypeTemplate()->Set(CcTest::isolate(), "v2", v8_num(10.1));
+ base2->PrototypeTemplate()->Set(isolate, "v2", v8_num(10.1));
LocalContext env;
@@ -1952,8 +1975,8 @@
THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) {
v8::HandleScope scope(CcTest::isolate());
- Handle<FunctionTemplate> parent = FunctionTemplate::New();
- Handle<FunctionTemplate> child = FunctionTemplate::New();
+ Handle<FunctionTemplate> parent = FunctionTemplate::New(CcTest::isolate());
+ Handle<FunctionTemplate> child = FunctionTemplate::New(CcTest::isolate());
child->Inherit(parent);
AddAccessor(parent, v8_str("age"),
SimpleAccessorGetter, SimpleAccessorSetter);
@@ -1969,9 +1992,10 @@
THREADED_TEST(EmptyInterceptorDoesNotShadowJSAccessors) {
- v8::HandleScope scope(CcTest::isolate());
- Handle<FunctionTemplate> parent = FunctionTemplate::New();
- Handle<FunctionTemplate> child = FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ Handle<FunctionTemplate> parent = FunctionTemplate::New(isolate);
+ Handle<FunctionTemplate> child = FunctionTemplate::New(isolate);
child->Inherit(parent);
AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter);
LocalContext env;
@@ -1990,9 +2014,10 @@
THREADED_TEST(EmptyInterceptorDoesNotAffectJSProperties) {
- v8::HandleScope scope(CcTest::isolate());
- Handle<FunctionTemplate> parent = FunctionTemplate::New();
- Handle<FunctionTemplate> child = FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ Handle<FunctionTemplate> parent = FunctionTemplate::New(isolate);
+ Handle<FunctionTemplate> child = FunctionTemplate::New(isolate);
child->Inherit(parent);
AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter);
LocalContext env;
@@ -2011,7 +2036,7 @@
THREADED_TEST(SwitchFromInterceptorToAccessor) {
v8::HandleScope scope(CcTest::isolate());
- Handle<FunctionTemplate> templ = FunctionTemplate::New();
+ Handle<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate());
AddAccessor(templ, v8_str("age"),
SimpleAccessorGetter, SimpleAccessorSetter);
AddInterceptor(templ, InterceptorGetter, InterceptorSetter);
@@ -2029,7 +2054,7 @@
THREADED_TEST(SwitchFromAccessorToInterceptor) {
v8::HandleScope scope(CcTest::isolate());
- Handle<FunctionTemplate> templ = FunctionTemplate::New();
+ Handle<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate());
AddAccessor(templ, v8_str("age"),
SimpleAccessorGetter, SimpleAccessorSetter);
AddInterceptor(templ, InterceptorGetter, InterceptorSetter);
@@ -2047,8 +2072,8 @@
THREADED_TEST(SwitchFromInterceptorToAccessorWithInheritance) {
v8::HandleScope scope(CcTest::isolate());
- Handle<FunctionTemplate> parent = FunctionTemplate::New();
- Handle<FunctionTemplate> child = FunctionTemplate::New();
+ Handle<FunctionTemplate> parent = FunctionTemplate::New(CcTest::isolate());
+ Handle<FunctionTemplate> child = FunctionTemplate::New(CcTest::isolate());
child->Inherit(parent);
AddAccessor(parent, v8_str("age"),
SimpleAccessorGetter, SimpleAccessorSetter);
@@ -2067,8 +2092,8 @@
THREADED_TEST(SwitchFromAccessorToInterceptorWithInheritance) {
v8::HandleScope scope(CcTest::isolate());
- Handle<FunctionTemplate> parent = FunctionTemplate::New();
- Handle<FunctionTemplate> child = FunctionTemplate::New();
+ Handle<FunctionTemplate> parent = FunctionTemplate::New(CcTest::isolate());
+ Handle<FunctionTemplate> child = FunctionTemplate::New(CcTest::isolate());
child->Inherit(parent);
AddAccessor(parent, v8_str("age"),
SimpleAccessorGetter, SimpleAccessorSetter);
@@ -2087,7 +2112,7 @@
THREADED_TEST(SwitchFromInterceptorToJSAccessor) {
v8::HandleScope scope(CcTest::isolate());
- Handle<FunctionTemplate> templ = FunctionTemplate::New();
+ Handle<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate());
AddInterceptor(templ, InterceptorGetter, InterceptorSetter);
LocalContext env;
env->Global()->Set(v8_str("Obj"), templ->GetFunction());
@@ -2112,7 +2137,7 @@
THREADED_TEST(SwitchFromJSAccessorToInterceptor) {
v8::HandleScope scope(CcTest::isolate());
- Handle<FunctionTemplate> templ = FunctionTemplate::New();
+ Handle<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate());
AddInterceptor(templ, InterceptorGetter, InterceptorSetter);
LocalContext env;
env->Global()->Set(v8_str("Obj"), templ->GetFunction());
@@ -2137,8 +2162,8 @@
THREADED_TEST(SwitchFromInterceptorToProperty) {
v8::HandleScope scope(CcTest::isolate());
- Handle<FunctionTemplate> parent = FunctionTemplate::New();
- Handle<FunctionTemplate> child = FunctionTemplate::New();
+ Handle<FunctionTemplate> parent = FunctionTemplate::New(CcTest::isolate());
+ Handle<FunctionTemplate> child = FunctionTemplate::New(CcTest::isolate());
child->Inherit(parent);
AddInterceptor(child, InterceptorGetter, InterceptorSetter);
LocalContext env;
@@ -2155,8 +2180,8 @@
THREADED_TEST(SwitchFromPropertyToInterceptor) {
v8::HandleScope scope(CcTest::isolate());
- Handle<FunctionTemplate> parent = FunctionTemplate::New();
- Handle<FunctionTemplate> child = FunctionTemplate::New();
+ Handle<FunctionTemplate> parent = FunctionTemplate::New(CcTest::isolate());
+ Handle<FunctionTemplate> child = FunctionTemplate::New(CcTest::isolate());
child->Inherit(parent);
AddInterceptor(child, InterceptorGetter, InterceptorSetter);
LocalContext env;
@@ -2174,7 +2199,8 @@
THREADED_TEST(NamedPropertyHandlerGetter) {
echo_named_call_count = 0;
v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
+ v8::Handle<v8::FunctionTemplate> templ =
+ v8::FunctionTemplate::New(CcTest::isolate());
templ->InstanceTemplate()->SetNamedPropertyHandler(EchoNamedProperty,
0, 0, 0, 0,
v8_str("data"));
@@ -2209,8 +2235,9 @@
THREADED_TEST(IndexedPropertyHandlerGetter) {
- v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
templ->InstanceTemplate()->SetIndexedPropertyHandler(EchoIndexedProperty,
0, 0, 0, 0,
v8_num(637));
@@ -2313,10 +2340,11 @@
THREADED_PROFILED_TEST(PropertyHandlerInPrototype) {
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
// Set up a prototype chain with three interceptors.
- v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
+ v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
templ->InstanceTemplate()->SetIndexedPropertyHandler(
CheckThisIndexedPropertyHandler,
CheckThisIndexedPropertySetter,
@@ -2380,8 +2408,9 @@
THREADED_TEST(PrePropertyHandler) {
- v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::FunctionTemplate> desc = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(isolate);
desc->InstanceTemplate()->SetNamedPropertyHandler(PrePropertyHandlerGet,
0,
PrePropertyHandlerQuery);
@@ -2437,12 +2466,13 @@
THREADED_TEST(DeepCrossLanguageRecursion) {
- v8::HandleScope scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New();
global->Set(v8_str("callScriptRecursively"),
- v8::FunctionTemplate::New(CallScriptRecursivelyCall));
+ v8::FunctionTemplate::New(isolate, CallScriptRecursivelyCall));
global->Set(v8_str("callFunctionRecursively"),
- v8::FunctionTemplate::New(CallFunctionRecursivelyCall));
+ v8::FunctionTemplate::New(isolate, CallFunctionRecursivelyCall));
LocalContext env(NULL, global);
env->Global()->Set(v8_str("depth"), v8::Integer::New(0));
@@ -2489,8 +2519,9 @@
THREADED_TEST(FunctionPrototype) {
- v8::HandleScope scope(CcTest::isolate());
- Local<v8::FunctionTemplate> Foo = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ Local<v8::FunctionTemplate> Foo = v8::FunctionTemplate::New(isolate);
Foo->PrototypeTemplate()->Set(v8_str("plak"), v8_num(321));
LocalContext env;
env->Global()->Set(v8_str("Foo"), Foo->GetFunction());
@@ -2501,9 +2532,10 @@
THREADED_TEST(InternalFields) {
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
- Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate();
instance_templ->SetInternalFieldCount(1);
Local<v8::Object> obj = templ->GetFunction()->NewInstance();
@@ -2549,9 +2581,10 @@
THREADED_TEST(InternalFieldsAlignedPointers) {
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
- Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate();
instance_templ->SetInternalFieldCount(1);
Local<v8::Object> obj = templ->GetFunction()->NewInstance();
@@ -3180,14 +3213,15 @@
THREADED_TEST(HiddenPropertiesWithInterceptors) {
LocalContext context;
- v8::HandleScope scope(context->GetIsolate());
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope scope(isolate);
interceptor_for_hidden_properties_called = false;
v8::Local<v8::String> key = v8_str("api-test::hidden-key");
// Associate an interceptor with an object and start setting hidden values.
- Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate);
Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate();
instance_templ->SetNamedPropertyHandler(InterceptorForHiddenProperties);
Local<v8::Function> function = fun_templ->GetFunction();
@@ -4198,9 +4232,10 @@
THREADED_TEST(Vector) {
- v8::HandleScope scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
Local<ObjectTemplate> global = ObjectTemplate::New();
- global->Set(v8_str("f"), v8::FunctionTemplate::New(HandleF));
+ global->Set(v8_str("f"), v8::FunctionTemplate::New(isolate, HandleF));
LocalContext context(0, global);
const char* fun = "f()";
@@ -4384,7 +4419,7 @@
v8::HandleScope scope(CcTest::isolate());
Local<ObjectTemplate> templ = ObjectTemplate::New();
templ->Set(v8_str("ProvokeOutOfMemory"),
- v8::FunctionTemplate::New(ProvokeOutOfMemory));
+ v8::FunctionTemplate::New(CcTest::isolate(), ProvokeOutOfMemory));
LocalContext context(0, templ);
v8::V8::IgnoreOutOfMemoryException();
Local<Value> result = CompileRun(
@@ -4664,7 +4699,7 @@
v8::HandleScope scope(CcTest::isolate());
Local<ObjectTemplate> templ = ObjectTemplate::New();
templ->Set(v8_str("ThrowFromC"),
- v8::FunctionTemplate::New(ThrowFromC));
+ v8::FunctionTemplate::New(CcTest::isolate(), ThrowFromC));
LocalContext context(0, templ);
CompileRun(
"var thrown = false;"
@@ -4682,7 +4717,7 @@
v8::HandleScope scope(CcTest::isolate());
Local<ObjectTemplate> templ = ObjectTemplate::New();
templ->Set(v8_str("ThrowFromC"),
- v8::FunctionTemplate::New(ThrowFromC));
+ v8::FunctionTemplate::New(CcTest::isolate(), ThrowFromC));
LocalContext context(0, templ);
v8::TryCatch try_catch;
CompileRun("ThrowFromC();");
@@ -4701,7 +4736,7 @@
v8::HandleScope scope(CcTest::isolate());
Local<ObjectTemplate> templ = ObjectTemplate::New();
templ->Set(v8_str("CCatcher"),
- v8::FunctionTemplate::New(CCatcher));
+ v8::FunctionTemplate::New(CcTest::isolate(), CCatcher));
LocalContext context(0, templ);
Local<Value> result = CompileRun("try {"
" try {"
@@ -4732,10 +4767,11 @@
// formatting. However, they are invoked when performing normal error
// string conversions.
TEST(APIThrowMessageOverwrittenToString) {
- v8::HandleScope scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
v8::V8::AddMessageListener(check_reference_error_message);
Local<ObjectTemplate> templ = ObjectTemplate::New();
- templ->Set(v8_str("fail"), v8::FunctionTemplate::New(Fail));
+ templ->Set(v8_str("fail"), v8::FunctionTemplate::New(isolate, Fail));
LocalContext context(NULL, templ);
CompileRun("asdf;");
CompileRun("var limit = {};"
@@ -4860,7 +4896,7 @@
v8::V8::AddMessageListener(receive_message);
Local<ObjectTemplate> templ = ObjectTemplate::New();
templ->Set(v8_str("ThrowFromC"),
- v8::FunctionTemplate::New(ThrowFromC));
+ v8::FunctionTemplate::New(CcTest::isolate(), ThrowFromC));
LocalContext context(0, templ);
CompileRun("ThrowFromC();");
CHECK(message_received);
@@ -4874,7 +4910,7 @@
v8::V8::AddMessageListener(receive_message);
Local<ObjectTemplate> templ = ObjectTemplate::New();
templ->Set(v8_str("ThrowFromC"),
- v8::FunctionTemplate::New(ThrowFromC));
+ v8::FunctionTemplate::New(CcTest::isolate(), ThrowFromC));
LocalContext context(0, templ);
v8::TryCatch try_catch;
try_catch.SetVerbose(true);
@@ -4905,7 +4941,7 @@
v8::HandleScope scope(CcTest::isolate());
Local<ObjectTemplate> templ = ObjectTemplate::New();
templ->Set(v8_str("ThrowFromC"),
- v8::FunctionTemplate::New(ThrowFromC));
+ v8::FunctionTemplate::New(CcTest::isolate(), ThrowFromC));
LocalContext context(0, templ);
v8::TryCatch try_catch;
@@ -5007,11 +5043,12 @@
// JS stack. This test therefore fails on the simulator. The test is
// not threaded to allow the threading tests to run on the simulator.
TEST(ExceptionOrder) {
- v8::HandleScope scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
Local<ObjectTemplate> templ = ObjectTemplate::New();
- templ->Set(v8_str("check"), v8::FunctionTemplate::New(JSCheck));
+ templ->Set(v8_str("check"), v8::FunctionTemplate::New(isolate, JSCheck));
templ->Set(v8_str("CThrowCountDown"),
- v8::FunctionTemplate::New(CThrowCountDown));
+ v8::FunctionTemplate::New(isolate, CThrowCountDown));
LocalContext context(0, templ);
CompileRun(
"function JSThrowCountDown(count, jsInterval, cInterval, expected) {"
@@ -5071,9 +5108,10 @@
THREADED_TEST(ThrowValues) {
- v8::HandleScope scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
Local<ObjectTemplate> templ = ObjectTemplate::New();
- templ->Set(v8_str("Throw"), v8::FunctionTemplate::New(ThrowValue));
+ templ->Set(v8_str("Throw"), v8::FunctionTemplate::New(isolate, ThrowValue));
LocalContext context(0, templ);
v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
"function Run(obj) {"
@@ -5140,10 +5178,11 @@
THREADED_TEST(TryCatchAndFinally) {
LocalContext context;
- v8::HandleScope scope(context->GetIsolate());
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope scope(isolate);
context->Global()->Set(
v8_str("native_with_try_catch"),
- v8::FunctionTemplate::New(WithTryCatch)->GetFunction());
+ v8::FunctionTemplate::New(isolate, WithTryCatch)->GetFunction());
v8::TryCatch try_catch;
CHECK(!try_catch.HasCaught());
CompileRun(
@@ -5209,12 +5248,13 @@
// This exercises the ability of TryCatch.ReThrow() to restore the
// inner pending Message before throwing the exception again.
TEST(TryCatchMixedNesting) {
- v8::HandleScope scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
v8::V8::Initialize();
v8::TryCatch try_catch;
Local<ObjectTemplate> templ = ObjectTemplate::New();
templ->Set(v8_str("TryCatchMixedNestingHelper"),
- v8::FunctionTemplate::New(TryCatchMixedNestingHelper));
+ v8::FunctionTemplate::New(isolate, TryCatchMixedNestingHelper));
LocalContext context(0, templ);
CompileRunWithOrigin("TryCatchMixedNestingHelper();\n", "outer", 1, 1);
TryCatchMixedNestingCheck(&try_catch);
@@ -5717,8 +5757,10 @@
// This is a regression test for http://crbug.com/20104. Map
// transitions should not interfere with post interceptor lookup.
THREADED_TEST(NamedInterceptorMapTransitionRead) {
- v8::HandleScope scope(CcTest::isolate());
- Local<v8::FunctionTemplate> function_template = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ Local<v8::FunctionTemplate> function_template =
+ v8::FunctionTemplate::New(isolate);
Local<v8::ObjectTemplate> instance_template
= function_template->InstanceTemplate();
instance_template->SetNamedPropertyHandler(SetXOnPrototypeGetter);
@@ -6174,9 +6216,11 @@
THREADED_TEST(MultiContexts) {
- v8::HandleScope scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
v8::Handle<ObjectTemplate> templ = ObjectTemplate::New();
- templ->Set(v8_str("dummy"), v8::FunctionTemplate::New(DummyCallHandler));
+ templ->Set(v8_str("dummy"), v8::FunctionTemplate::New(isolate,
+ DummyCallHandler));
Local<String> password = v8_str("Password");
@@ -6263,7 +6307,8 @@
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> desc =
+ v8::FunctionTemplate::New(env->GetIsolate());
desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable
Local<v8::Object> obj = desc->GetFunction()->NewInstance();
@@ -6304,9 +6349,10 @@
THREADED_TEST(VoidLiteral) {
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
- Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(isolate);
desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable
Local<v8::Object> obj = desc->GetFunction()->NewInstance();
@@ -6347,9 +6393,10 @@
THREADED_TEST(ExtensibleOnUndetectable) {
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
- Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(isolate);
desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable
Local<v8::Object> obj = desc->GetFunction()->NewInstance();
@@ -6483,7 +6530,7 @@
v8::HandleScope handle_scope(isolate);
Local<ObjectTemplate> global_template = ObjectTemplate::New();
global_template->Set(v8_str("JSNI_Log"),
- v8::FunctionTemplate::New(HandleLogDelegator));
+ v8::FunctionTemplate::New(isolate, HandleLogDelegator));
v8::Local<Context> context = Context::New(isolate, 0, global_template);
Context::Scope context_scope(context);
Script::Compile(v8_str("JSNI_Log('LOG')"))->Run();
@@ -6716,7 +6763,7 @@
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate(
v8::Isolate* isolate,
v8::Handle<v8::String> name) {
- return v8::FunctionTemplate::New(function_);
+ return v8::FunctionTemplate::New(isolate, function_);
}
static void Echo(const v8::FunctionCallbackInfo<v8::Value>& args) {
@@ -6846,11 +6893,11 @@
v8::Isolate* isolate, v8::Handle<String> name) {
lookup_count++;
if (name->Equals(v8_str("A"))) {
- return v8::FunctionTemplate::New(CallFun, v8::Integer::New(8));
+ return v8::FunctionTemplate::New(isolate, CallFun, v8::Integer::New(8));
} else if (name->Equals(v8_str("B"))) {
- return v8::FunctionTemplate::New(CallFun, v8::Integer::New(7));
+ return v8::FunctionTemplate::New(isolate, CallFun, v8::Integer::New(7));
} else if (name->Equals(v8_str("C"))) {
- return v8::FunctionTemplate::New(CallFun, v8::Integer::New(6));
+ return v8::FunctionTemplate::New(isolate, CallFun, v8::Integer::New(6));
} else {
return v8::Handle<v8::FunctionTemplate>();
}
@@ -7204,9 +7251,11 @@
THREADED_TEST(Arguments) {
- v8::HandleScope scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New();
- global->Set(v8_str("f"), v8::FunctionTemplate::New(ArgumentsTestCallback));
+ global->Set(v8_str("f"),
+ v8::FunctionTemplate::New(isolate, ArgumentsTestCallback));
LocalContext context(NULL, global);
args_fun = context->Global()->Get(v8_str("f")).As<Function>();
v8_compile("f(1, 2, 3)")->Run();
@@ -8062,10 +8111,11 @@
THREADED_TEST(TypeSwitch) {
- v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::FunctionTemplate> templ1 = v8::FunctionTemplate::New();
- v8::Handle<v8::FunctionTemplate> templ2 = v8::FunctionTemplate::New();
- v8::Handle<v8::FunctionTemplate> templ3 = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::FunctionTemplate> templ1 = v8::FunctionTemplate::New(isolate);
+ v8::Handle<v8::FunctionTemplate> templ2 = v8::FunctionTemplate::New(isolate);
+ v8::Handle<v8::FunctionTemplate> templ3 = v8::FunctionTemplate::New(isolate);
v8::Handle<v8::FunctionTemplate> templs[3] = { templ1, templ2, templ3 };
v8::Handle<v8::TypeSwitch> type_switch = v8::TypeSwitch::New(3, templs);
LocalContext context;
@@ -8143,10 +8193,12 @@
TEST(ApiUncaughtException) {
report_count = 0;
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
v8::V8::AddMessageListener(ApiUncaughtExceptionTestListener);
- Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(TroubleCallback);
+ Local<v8::FunctionTemplate> fun =
+ v8::FunctionTemplate::New(isolate, TroubleCallback);
v8::Local<v8::Object> global = env->Global();
global->Set(v8_str("trouble"), fun->GetFunction());
@@ -8183,10 +8235,12 @@
TEST(ExceptionInNativeScript) {
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
v8::V8::AddMessageListener(ExceptionInNativeScriptTestListener);
- Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(TroubleCallback);
+ Local<v8::FunctionTemplate> fun =
+ v8::FunctionTemplate::New(isolate, TroubleCallback);
v8::Local<v8::Object> global = env->Global();
global->Set(v8_str("trouble"), fun->GetFunction());
@@ -8196,7 +8250,7 @@
" var o = {};\n"
" new o.foo();\n"
"};"),
- v8::String::NewFromUtf8(env->GetIsolate(), script_resource_name))->Run();
+ v8::String::NewFromUtf8(isolate, script_resource_name))->Run();
Local<Value> trouble = global->Get(v8_str("trouble"));
CHECK(trouble->IsFunction());
Function::Cast(*trouble)->Call(global, 0, NULL);
@@ -8769,8 +8823,8 @@
global_template->SetAccessorProperty(
v8_str("accessible_js_prop"),
- v8::FunctionTemplate::New(EchoGetter),
- v8::FunctionTemplate::New(EchoSetter),
+ v8::FunctionTemplate::New(isolate, EchoGetter),
+ v8::FunctionTemplate::New(isolate, EchoSetter),
v8::None,
v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE));
@@ -8782,8 +8836,8 @@
global_template->SetAccessorProperty(
v8_str("blocked_js_prop"),
- v8::FunctionTemplate::New(UnreachableFunction),
- v8::FunctionTemplate::New(UnreachableFunction),
+ v8::FunctionTemplate::New(isolate, UnreachableFunction),
+ v8::FunctionTemplate::New(isolate, UnreachableFunction),
v8::None,
v8::DEFAULT);
@@ -9216,7 +9270,8 @@
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
- v8::Handle<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New();
+ v8::Handle<v8::FunctionTemplate> func_template =
+ v8::FunctionTemplate::New(isolate);
v8::Handle<v8::ObjectTemplate> global_template =
func_template->InstanceTemplate();
@@ -9582,14 +9637,15 @@
THREADED_TEST(InstanceProperties) {
LocalContext context;
- v8::HandleScope handle_scope(context->GetIsolate());
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope handle_scope(isolate);
- Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
Local<ObjectTemplate> instance = t->InstanceTemplate();
instance->Set(v8_str("x"), v8_num(42));
instance->Set(v8_str("f"),
- v8::FunctionTemplate::New(InstanceFunctionCallback));
+ v8::FunctionTemplate::New(isolate, InstanceFunctionCallback));
Local<Value> o = t->GetFunction()->NewInstance();
@@ -9610,17 +9666,19 @@
THREADED_TEST(GlobalObjectInstanceProperties) {
- v8::HandleScope handle_scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope handle_scope(isolate);
Local<Value> global_object;
- Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
t->InstanceTemplate()->SetNamedPropertyHandler(
GlobalObjectInstancePropertiesGet);
Local<ObjectTemplate> instance_template = t->InstanceTemplate();
instance_template->Set(v8_str("x"), v8_num(42));
instance_template->Set(v8_str("f"),
- v8::FunctionTemplate::New(InstanceFunctionCallback));
+ v8::FunctionTemplate::New(isolate,
+ InstanceFunctionCallback));
// The script to check how Crankshaft compiles missing global function
// invocations. function g is not defined and should throw on call.
@@ -9666,11 +9724,12 @@
THREADED_TEST(CallKnownGlobalReceiver) {
- v8::HandleScope handle_scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope handle_scope(isolate);
Local<Value> global_object;
- Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
Local<ObjectTemplate> instance_template = t->InstanceTemplate();
// The script to check that we leave global object not
@@ -9745,19 +9804,22 @@
THREADED_TEST(ShadowObject) {
shadow_y = shadow_y_setter_call_count = shadow_y_getter_call_count = 0;
- v8::HandleScope handle_scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope handle_scope(isolate);
Local<ObjectTemplate> global_template = v8::ObjectTemplate::New();
LocalContext context(NULL, global_template);
- Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
t->InstanceTemplate()->SetNamedPropertyHandler(ShadowNamedGet);
t->InstanceTemplate()->SetIndexedPropertyHandler(ShadowIndexedGet);
Local<ObjectTemplate> proto = t->PrototypeTemplate();
Local<ObjectTemplate> instance = t->InstanceTemplate();
proto->Set(v8_str("f"),
- v8::FunctionTemplate::New(ShadowFunctionCallback, Local<Value>()));
+ v8::FunctionTemplate::New(isolate,
+ ShadowFunctionCallback,
+ Local<Value>()));
proto->Set(v8_str("x"), v8_num(12));
instance->SetAccessor(v8_str("y"), ShadowYGetter, ShadowYSetter);
@@ -9786,17 +9848,18 @@
THREADED_TEST(HiddenPrototype) {
LocalContext context;
- v8::HandleScope handle_scope(context->GetIsolate());
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope handle_scope(isolate);
- Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
t0->InstanceTemplate()->Set(v8_str("x"), v8_num(0));
- Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
t1->SetHiddenPrototype(true);
t1->InstanceTemplate()->Set(v8_str("y"), v8_num(1));
- Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate);
t2->SetHiddenPrototype(true);
t2->InstanceTemplate()->Set(v8_str("z"), v8_num(2));
- Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate);
t3->InstanceTemplate()->Set(v8_str("u"), v8_num(3));
Local<v8::Object> o0 = t0->GetFunction()->NewInstance();
@@ -9830,12 +9893,13 @@
THREADED_TEST(HiddenPrototypeSet) {
LocalContext context;
- v8::HandleScope handle_scope(context->GetIsolate());
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope handle_scope(isolate);
- Local<v8::FunctionTemplate> ot = v8::FunctionTemplate::New();
- Local<v8::FunctionTemplate> ht = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> ot = v8::FunctionTemplate::New(isolate);
+ Local<v8::FunctionTemplate> ht = v8::FunctionTemplate::New(isolate);
ht->SetHiddenPrototype(true);
- Local<v8::FunctionTemplate> pt = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> pt = v8::FunctionTemplate::New(isolate);
ht->InstanceTemplate()->Set(v8_str("x"), v8_num(0));
Local<v8::Object> o = ot->GetFunction()->NewInstance();
@@ -9874,7 +9938,7 @@
LocalContext context;
v8::HandleScope handle_scope(context->GetIsolate());
- Handle<FunctionTemplate> t = FunctionTemplate::New();
+ Handle<FunctionTemplate> t = FunctionTemplate::New(context->GetIsolate());
t->SetHiddenPrototype(true);
t->InstanceTemplate()->Set(v8_str("foo"), v8_num(75));
Handle<Object> p = t->GetFunction()->NewInstance();
@@ -9890,17 +9954,18 @@
THREADED_TEST(SetPrototype) {
LocalContext context;
- v8::HandleScope handle_scope(context->GetIsolate());
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope handle_scope(isolate);
- Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
t0->InstanceTemplate()->Set(v8_str("x"), v8_num(0));
- Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
t1->SetHiddenPrototype(true);
t1->InstanceTemplate()->Set(v8_str("y"), v8_num(1));
- Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate);
t2->SetHiddenPrototype(true);
t2->InstanceTemplate()->Set(v8_str("z"), v8_num(2));
- Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate);
t3->InstanceTemplate()->Set(v8_str("u"), v8_num(3));
Local<v8::Object> o0 = t0->GetFunction()->NewInstance();
@@ -9951,20 +10016,21 @@
THREADED_TEST(Regress91517) {
i::FLAG_allow_natives_syntax = true;
LocalContext context;
- v8::HandleScope handle_scope(context->GetIsolate());
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope handle_scope(isolate);
- Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
t1->SetHiddenPrototype(true);
t1->InstanceTemplate()->Set(v8_str("foo"), v8_num(1));
- Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate);
t2->SetHiddenPrototype(true);
t2->InstanceTemplate()->Set(v8_str("fuz1"), v8_num(2));
t2->InstanceTemplate()->Set(v8_str("objects"), v8::Object::New());
t2->InstanceTemplate()->Set(v8_str("fuz2"), v8_num(2));
- Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate);
t3->SetHiddenPrototype(true);
t3->InstanceTemplate()->Set(v8_str("boo"), v8_num(3));
- Local<v8::FunctionTemplate> t4 = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t4 = v8::FunctionTemplate::New(isolate);
t4->InstanceTemplate()->Set(v8_str("baz"), v8_num(4));
// Force dictionary-based properties.
@@ -10001,9 +10067,10 @@
THREADED_TEST(FunctionReadOnlyPrototype) {
LocalContext context;
- v8::HandleScope handle_scope(context->GetIsolate());
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope handle_scope(isolate);
- Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
t1->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42));
t1->ReadOnlyPrototype();
context->Global()->Set(v8_str("func1"), t1->GetFunction());
@@ -10017,7 +10084,7 @@
CHECK_EQ(42,
CompileRun("func1.prototype = {}; func1.prototype.x")->Int32Value());
- Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate);
t2->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42));
context->Global()->Set(v8_str("func2"), t2->GetFunction());
// Default value of ReadOnly flag.
@@ -10032,9 +10099,10 @@
THREADED_TEST(SetPrototypeThrows) {
LocalContext context;
- v8::HandleScope handle_scope(context->GetIsolate());
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope handle_scope(isolate);
- Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
Local<v8::Object> o0 = t->GetFunction()->NewInstance();
Local<v8::Object> o1 = t->GetFunction()->NewInstance();
@@ -10053,9 +10121,10 @@
THREADED_TEST(FunctionRemovePrototype) {
LocalContext context;
- v8::HandleScope handle_scope(context->GetIsolate());
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope handle_scope(isolate);
- Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
t1->RemovePrototype();
Local<v8::Function> fun = t1->GetFunction();
context->Global()->Set(v8_str("fun"), fun);
@@ -10096,8 +10165,9 @@
THREADED_TEST(Constructor) {
LocalContext context;
- v8::HandleScope handle_scope(context->GetIsolate());
- Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope handle_scope(isolate);
+ Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
templ->SetClassName(v8_str("Fun"));
Local<Function> cons = templ->GetFunction();
context->Global()->Set(v8_str("Fun"), cons);
@@ -10264,7 +10334,7 @@
// Check whether constructor returns with an object or non-object.
{ Local<FunctionTemplate> function_template =
- FunctionTemplate::New(FakeConstructorCallback);
+ FunctionTemplate::New(isolate, FakeConstructorCallback);
Local<Function> function = function_template->GetFunction();
Local<Object> instance1 = function;
context->Global()->Set(v8_str("obj4"), instance1);
@@ -10307,8 +10377,9 @@
THREADED_TEST(FunctionDescriptorException) {
LocalContext context;
- v8::HandleScope handle_scope(context->GetIsolate());
- Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope handle_scope(isolate);
+ Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
templ->SetClassName(v8_str("Fun"));
Local<Function> cons = templ->GetFunction();
context->Global()->Set(v8_str("Fun"), cons);
@@ -10525,9 +10596,10 @@
// functions.
THREADED_TEST(CallAsFunction) {
LocalContext context;
- v8::HandleScope scope(context->GetIsolate());
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope scope(isolate);
- { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
+ { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
Local<ObjectTemplate> instance_template = t->InstanceTemplate();
instance_template->SetCallAsFunctionHandler(call_as_function);
Local<v8::Object> instance = t->GetFunction()->NewInstance();
@@ -10580,7 +10652,7 @@
CHECK_EQ(28, value->Int32Value());
}
- { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
+ { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
Local<ObjectTemplate> instance_template(t->InstanceTemplate());
USE(instance_template);
Local<v8::Object> instance = t->GetFunction()->NewInstance();
@@ -10609,7 +10681,7 @@
try_catch.Reset();
}
- { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
+ { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
Local<ObjectTemplate> instance_template = t->InstanceTemplate();
instance_template->SetCallAsFunctionHandler(ThrowValue);
Local<v8::Object> instance = t->GetFunction()->NewInstance();
@@ -10633,8 +10705,7 @@
try_catch.Reset();
}
- { v8::Isolate* isolate = context->GetIsolate();
- Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
+ { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
Local<ObjectTemplate> instance_template = t->InstanceTemplate();
instance_template->SetCallAsFunctionHandler(ReturnThis);
Local<v8::Object> instance = t->GetFunction()->NewInstance();
@@ -10656,8 +10727,7 @@
CHECK(a5->StrictEquals(instance));
}
- { v8::Isolate* isolate = context->GetIsolate();
- CompileRun(
+ { CompileRun(
"function ReturnThisSloppy() {"
" return this;"
"}"
@@ -10713,7 +10783,8 @@
// Check whether a non-function object is callable.
THREADED_TEST(CallableObject) {
LocalContext context;
- v8::HandleScope scope(context->GetIsolate());
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope scope(isolate);
{ Local<ObjectTemplate> instance_template = ObjectTemplate::New();
instance_template->SetCallAsFunctionHandler(call_as_function);
@@ -10733,7 +10804,7 @@
}
{ Local<FunctionTemplate> function_template =
- FunctionTemplate::New(call_as_function);
+ FunctionTemplate::New(isolate, call_as_function);
Local<Function> function = function_template->GetFunction();
Local<Object> instance = function;
v8::TryCatch try_catch;
@@ -10742,7 +10813,7 @@
CHECK(!try_catch.HasCaught());
}
- { Local<FunctionTemplate> function_template = FunctionTemplate::New();
+ { Local<FunctionTemplate> function_template = FunctionTemplate::New(isolate);
Local<Function> function = function_template->GetFunction();
Local<Object> instance = function;
v8::TryCatch try_catch;
@@ -10804,8 +10875,9 @@
THREADED_TEST(InterceptorHasOwnProperty) {
LocalContext context;
- v8::HandleScope scope(context->GetIsolate());
- Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope scope(isolate);
+ Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate);
Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate();
instance_templ->SetNamedPropertyHandler(InterceptorHasOwnPropertyGetter);
Local<Function> function = fun_templ->GetFunction();
@@ -10835,8 +10907,9 @@
THREADED_TEST(InterceptorHasOwnPropertyCausingGC) {
LocalContext context;
- v8::HandleScope scope(context->GetIsolate());
- Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope scope(isolate);
+ Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate);
Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate();
instance_templ->SetNamedPropertyHandler(InterceptorHasOwnPropertyGetterGC);
Local<Function> function = fun_templ->GetFunction();
@@ -11666,10 +11739,12 @@
THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) {
LocalContext context;
- v8::HandleScope scope(context->GetIsolate());
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope scope(isolate);
v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New();
- nativeobject_templ->Set(context->GetIsolate(), "callback",
- v8::FunctionTemplate::New(DirectApiCallback));
+ nativeobject_templ->Set(isolate, "callback",
+ v8::FunctionTemplate::New(isolate,
+ DirectApiCallback));
v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance();
context->Global()->Set(v8_str("nativeobject"), nativeobject_obj);
// call the api function multiple times to ensure direct call stub creation.
@@ -11691,10 +11766,13 @@
THREADED_TEST(CallICFastApi_DirectCall_Throw) {
LocalContext context;
- v8::HandleScope scope(context->GetIsolate());
- v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New();
- nativeobject_templ->Set(context->GetIsolate(), "callback",
- v8::FunctionTemplate::New(ThrowingDirectApiCallback));
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::ObjectTemplate> nativeobject_templ =
+ v8::ObjectTemplate::New();
+ nativeobject_templ->Set(isolate, "callback",
+ v8::FunctionTemplate::New(isolate,
+ ThrowingDirectApiCallback));
v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance();
context->Global()->Set(v8_str("nativeobject"), nativeobject_obj);
// call the api function multiple times to ensure direct call stub creation.
@@ -11775,10 +11853,13 @@
THREADED_PROFILED_TEST(InterceptorCallICFastApi_TrivialSignature) {
int interceptor_call_count = 0;
- v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::FunctionTemplate::New(isolate);
v8::Handle<v8::FunctionTemplate> method_templ =
- v8::FunctionTemplate::New(FastApiCallback_TrivialSignature,
+ v8::FunctionTemplate::New(isolate,
+ FastApiCallback_TrivialSignature,
v8_str("method_data"),
v8::Handle<v8::Signature>());
v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
@@ -11786,7 +11867,7 @@
v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
templ->SetNamedPropertyHandler(
InterceptorCallICFastApi, NULL, NULL, NULL, NULL,
- v8::External::New(CcTest::isolate(), &interceptor_call_count));
+ v8::External::New(isolate, &interceptor_call_count));
LocalContext context;
v8::Handle<v8::Function> fun = fun_templ->GetFunction();
GenerateSomeGarbage();
@@ -11803,18 +11884,20 @@
THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature) {
int interceptor_call_count = 0;
- v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::FunctionTemplate::New(isolate);
v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
- FastApiCallback_SimpleSignature, v8_str("method_data"),
- v8::Signature::New(CcTest::isolate(), fun_templ));
+ isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
+ v8::Signature::New(isolate, fun_templ));
v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
fun_templ->SetHiddenPrototype(true);
v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
templ->SetNamedPropertyHandler(
InterceptorCallICFastApi, NULL, NULL, NULL, NULL,
- v8::External::New(CcTest::isolate(), &interceptor_call_count));
+ v8::External::New(isolate, &interceptor_call_count));
LocalContext context;
v8::Handle<v8::Function> fun = fun_templ->GetFunction();
GenerateSomeGarbage();
@@ -11834,18 +11917,20 @@
THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) {
int interceptor_call_count = 0;
- v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::FunctionTemplate::New(isolate);
v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
- FastApiCallback_SimpleSignature, v8_str("method_data"),
- v8::Signature::New(CcTest::isolate(), fun_templ));
+ isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
+ v8::Signature::New(isolate, fun_templ));
v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
fun_templ->SetHiddenPrototype(true);
v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
templ->SetNamedPropertyHandler(
InterceptorCallICFastApi, NULL, NULL, NULL, NULL,
- v8::External::New(CcTest::isolate(), &interceptor_call_count));
+ v8::External::New(isolate, &interceptor_call_count));
LocalContext context;
v8::Handle<v8::Function> fun = fun_templ->GetFunction();
GenerateSomeGarbage();
@@ -11871,18 +11956,20 @@
THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) {
int interceptor_call_count = 0;
- v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::FunctionTemplate::New(isolate);
v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
- FastApiCallback_SimpleSignature, v8_str("method_data"),
- v8::Signature::New(CcTest::isolate(), fun_templ));
+ isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
+ v8::Signature::New(isolate, fun_templ));
v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
fun_templ->SetHiddenPrototype(true);
v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
templ->SetNamedPropertyHandler(
InterceptorCallICFastApi, NULL, NULL, NULL, NULL,
- v8::External::New(CcTest::isolate(), &interceptor_call_count));
+ v8::External::New(isolate, &interceptor_call_count));
LocalContext context;
v8::Handle<v8::Function> fun = fun_templ->GetFunction();
GenerateSomeGarbage();
@@ -11908,18 +11995,20 @@
THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) {
int interceptor_call_count = 0;
- v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::FunctionTemplate::New(isolate);
v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
- FastApiCallback_SimpleSignature, v8_str("method_data"),
- v8::Signature::New(CcTest::isolate(), fun_templ));
+ isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
+ v8::Signature::New(isolate, fun_templ));
v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
fun_templ->SetHiddenPrototype(true);
v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
templ->SetNamedPropertyHandler(
InterceptorCallICFastApi, NULL, NULL, NULL, NULL,
- v8::External::New(CcTest::isolate(), &interceptor_call_count));
+ v8::External::New(isolate, &interceptor_call_count));
LocalContext context;
v8::Handle<v8::Function> fun = fun_templ->GetFunction();
GenerateSomeGarbage();
@@ -11948,18 +12037,20 @@
THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) {
int interceptor_call_count = 0;
- v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::FunctionTemplate::New(isolate);
v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
- FastApiCallback_SimpleSignature, v8_str("method_data"),
- v8::Signature::New(CcTest::isolate(), fun_templ));
+ isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
+ v8::Signature::New(isolate, fun_templ));
v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
fun_templ->SetHiddenPrototype(true);
v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
templ->SetNamedPropertyHandler(
InterceptorCallICFastApi, NULL, NULL, NULL, NULL,
- v8::External::New(CcTest::isolate(), &interceptor_call_count));
+ v8::External::New(isolate, &interceptor_call_count));
LocalContext context;
v8::Handle<v8::Function> fun = fun_templ->GetFunction();
GenerateSomeGarbage();
@@ -11987,10 +12078,13 @@
THREADED_PROFILED_TEST(CallICFastApi_TrivialSignature) {
- v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::FunctionTemplate::New(isolate);
v8::Handle<v8::FunctionTemplate> method_templ =
- v8::FunctionTemplate::New(FastApiCallback_TrivialSignature,
+ v8::FunctionTemplate::New(isolate,
+ FastApiCallback_TrivialSignature,
v8_str("method_data"),
v8::Handle<v8::Signature>());
v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
@@ -12012,11 +12106,13 @@
THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature) {
- v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::FunctionTemplate::New(isolate);
v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
- FastApiCallback_SimpleSignature, v8_str("method_data"),
- v8::Signature::New(CcTest::isolate(), fun_templ));
+ isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
+ v8::Signature::New(isolate, fun_templ));
v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
fun_templ->SetHiddenPrototype(true);
@@ -12040,11 +12136,13 @@
THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss1) {
- v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::FunctionTemplate::New(isolate);
v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
- FastApiCallback_SimpleSignature, v8_str("method_data"),
- v8::Signature::New(CcTest::isolate(), fun_templ));
+ isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
+ v8::Signature::New(isolate, fun_templ));
v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
fun_templ->SetHiddenPrototype(true);
@@ -12073,11 +12171,13 @@
THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss2) {
- v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::FunctionTemplate::New(isolate);
v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
- FastApiCallback_SimpleSignature, v8_str("method_data"),
- v8::Signature::New(CcTest::isolate(), fun_templ));
+ isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
+ v8::Signature::New(isolate, fun_templ));
v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
fun_templ->SetHiddenPrototype(true);
@@ -12109,11 +12209,13 @@
THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) {
- v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::FunctionTemplate> fun_templ =
+ v8::FunctionTemplate::New(isolate);
v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
- FastApiCallback_SimpleSignature, v8_str("method_data"),
- v8::Signature::New(CcTest::isolate(), fun_templ));
+ isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
+ v8::Signature::New(isolate, fun_templ));
v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
proto_templ->Set(v8_str("method"), method_templ);
fun_templ->SetHiddenPrototype(true);
@@ -12458,8 +12560,9 @@
THREADED_TEST(NamedPropertyHandlerGetterAttributes) {
- v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
templ->InstanceTemplate()->SetNamedPropertyHandler(InterceptorLoadXICGetter);
LocalContext env;
env->Global()->Set(v8_str("obj"),
@@ -12481,7 +12584,7 @@
LocalContext context;
HandleScope scope(context->GetIsolate());
- Local<FunctionTemplate> templ = FunctionTemplate::New();
+ Local<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate());
Local<ObjectTemplate> instance_templ = templ->InstanceTemplate();
instance_templ->SetAccessor(v8_str("f"), ThrowingGetter);
@@ -12571,10 +12674,12 @@
THREADED_TEST(ExceptionsDoNotPropagatePastTryCatch) {
LocalContext context;
- HandleScope scope(context->GetIsolate());
+ v8::Isolate* isolate = context->GetIsolate();
+ HandleScope scope(isolate);
Local<Function> func =
- FunctionTemplate::New(ThrowingCallbackWithTryCatch)->GetFunction();
+ FunctionTemplate::New(isolate,
+ ThrowingCallbackWithTryCatch)->GetFunction();
context->Global()->Set(v8_str("func"), func);
MessageCallback callbacks[] =
@@ -12615,16 +12720,17 @@
THREADED_TEST(Overriding) {
i::FLAG_es5_readonly = true;
LocalContext context;
- v8::HandleScope scope(context->GetIsolate());
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope scope(isolate);
// Parent template.
- Local<v8::FunctionTemplate> parent_templ = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> parent_templ = v8::FunctionTemplate::New(isolate);
Local<ObjectTemplate> parent_instance_templ =
parent_templ->InstanceTemplate();
parent_instance_templ->SetAccessor(v8_str("f"), ParentGetter);
// Template that inherits from the parent template.
- Local<v8::FunctionTemplate> child_templ = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> child_templ = v8::FunctionTemplate::New(isolate);
Local<ObjectTemplate> child_instance_templ =
child_templ->InstanceTemplate();
child_templ->Inherit(parent_templ);
@@ -12678,10 +12784,11 @@
THREADED_TEST(IsConstructCall) {
- v8::HandleScope scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
// Function template with call handler.
- Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
templ->SetCallHandler(IsConstructHandler);
LocalContext context;
@@ -12695,8 +12802,9 @@
THREADED_TEST(ObjectProtoToString) {
- v8::HandleScope scope(CcTest::isolate());
- Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
templ->SetClassName(v8_str("MyClass"));
LocalContext context;
@@ -12957,11 +13065,13 @@
// These are locking tests that don't need to be run again
// as part of the locking aggregation tests.
TEST(NestedLockers) {
- v8::Locker locker(CcTest::isolate());
- CHECK(v8::Locker::IsLocked(CcTest::isolate()));
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::Locker locker(isolate);
+ CHECK(v8::Locker::IsLocked(isolate));
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(ThrowInJS);
+ Local<v8::FunctionTemplate> fun_templ =
+ v8::FunctionTemplate::New(isolate, ThrowInJS);
Local<Function> fun = fun_templ->GetFunction();
env->Global()->Set(v8_str("throw_in_js"), fun);
Local<Script> script = v8_compile("(function () {"
@@ -12983,7 +13093,7 @@
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
Local<v8::FunctionTemplate> fun_templ =
- v8::FunctionTemplate::New(ThrowInJSNoCatch);
+ v8::FunctionTemplate::New(env->GetIsolate(), ThrowInJSNoCatch);
Local<Function> fun = fun_templ->GetFunction();
env->Global()->Set(v8_str("throw_in_js"), fun);
Local<Script> script = v8_compile("(function () {"
@@ -13019,7 +13129,7 @@
v8::HandleScope scope(CcTest::isolate());
LocalContext env;
Local<v8::FunctionTemplate> fun_templ =
- v8::FunctionTemplate::New(UnlockForAMoment);
+ v8::FunctionTemplate::New(CcTest::isolate(), UnlockForAMoment);
Local<Function> fun = fun_templ->GetFunction();
env->Global()->Set(v8_str("unlock_for_a_moment"), fun);
Local<Script> script = v8_compile("(function () {"
@@ -13033,7 +13143,7 @@
v8::HandleScope scope(CcTest::isolate());
LocalContext env;
Local<v8::FunctionTemplate> fun_templ =
- v8::FunctionTemplate::New(UnlockForAMoment);
+ v8::FunctionTemplate::New(CcTest::isolate(), UnlockForAMoment);
Local<Function> fun = fun_templ->GetFunction();
env->Global()->Set(v8_str("unlock_for_a_moment"), fun);
Local<Script> script = v8_compile("(function () {"
@@ -13540,7 +13650,7 @@
env->Enter();
Local<ObjectTemplate> t = ObjectTemplate::New();
- t->Set(v8_str("asdf"), v8::FunctionTemplate::New(RuntimeCallback));
+ t->Set(v8_str("asdf"), v8::FunctionTemplate::New(isolate, RuntimeCallback));
env->Global()->Set(v8_str("obj"), t->NewInstance());
const char* script =
@@ -14028,9 +14138,11 @@
THREADED_TEST(CallbackFunctionName) {
LocalContext context;
- v8::HandleScope scope(context->GetIsolate());
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope scope(isolate);
Local<ObjectTemplate> t = ObjectTemplate::New();
- t->Set(v8_str("asdf"), v8::FunctionTemplate::New(FunctionNameCallback));
+ t->Set(v8_str("asdf"),
+ v8::FunctionTemplate::New(isolate, FunctionNameCallback));
context->Global()->Set(v8_str("obj"), t->NewInstance());
v8::Handle<v8::Value> value = CompileRun("obj.asdf.name");
CHECK(value->IsString());
@@ -15208,7 +15320,7 @@
// Create an object with a C++ callback in context0.
calling_context0->Enter();
Local<v8::FunctionTemplate> callback_templ =
- v8::FunctionTemplate::New(GetCallingContextCallback);
+ v8::FunctionTemplate::New(isolate, GetCallingContextCallback);
calling_context0->Global()->Set(v8_str("callback"),
callback_templ->GetFunction());
calling_context0->Exit();
@@ -15255,15 +15367,17 @@
// See http://code.google.com/p/v8/issues/detail?id=398
THREADED_TEST(ReplaceConstantFunction) {
LocalContext context;
- v8::HandleScope scope(context->GetIsolate());
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope scope(isolate);
v8::Handle<v8::Object> obj = v8::Object::New();
- v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New();
+ v8::Handle<v8::FunctionTemplate> func_templ =
+ v8::FunctionTemplate::New(isolate);
v8::Handle<v8::String> foo_string =
- v8::String::NewFromUtf8(context->GetIsolate(), "foo");
+ v8::String::NewFromUtf8(isolate, "foo");
obj->Set(foo_string, func_templ->GetFunction());
v8::Handle<v8::Object> obj_clone = obj->Clone();
obj_clone->Set(foo_string,
- v8::String::NewFromUtf8(context->GetIsolate(), "Hello"));
+ v8::String::NewFromUtf8(isolate, "Hello"));
CHECK(!obj->Get(foo_string)->IsUndefined());
}
@@ -16665,12 +16779,13 @@
// TODO(3074796): Reenable this as a THREADED_TEST once it passes.
// THREADED_TEST(CaptureStackTrace) {
TEST(CaptureStackTrace) {
- v8::HandleScope scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
v8::Handle<v8::String> origin =
- v8::String::NewFromUtf8(CcTest::isolate(), "capture-stack-trace-test");
+ v8::String::NewFromUtf8(isolate, "capture-stack-trace-test");
Local<ObjectTemplate> templ = ObjectTemplate::New();
templ->Set(v8_str("AnalyzeStackInNativeCode"),
- v8::FunctionTemplate::New(AnalyzeStackInNativeCode));
+ v8::FunctionTemplate::New(isolate, AnalyzeStackInNativeCode));
LocalContext context(0, templ);
// Test getting OVERVIEW information. Should ignore information that is not
@@ -16685,7 +16800,7 @@
"}\n"
"var x;eval('new foo();');";
v8::Handle<v8::String> overview_src =
- v8::String::NewFromUtf8(CcTest::isolate(), overview_source);
+ v8::String::NewFromUtf8(isolate, overview_source);
v8::Handle<Value> overview_result(
v8::Script::New(overview_src, origin)->Run());
CHECK(!overview_result.IsEmpty());
@@ -16701,7 +16816,7 @@
"}\n"
"eval('new baz();');";
v8::Handle<v8::String> detailed_src =
- v8::String::NewFromUtf8(CcTest::isolate(), detailed_source);
+ v8::String::NewFromUtf8(isolate, detailed_source);
// Make the script using a non-zero line and column offset.
v8::Handle<v8::Integer> line_offset = v8::Integer::New(3);
v8::Handle<v8::Integer> column_offset = v8::Integer::New(5);
@@ -16917,10 +17032,12 @@
TEST(SourceURLInStackTrace) {
- v8::HandleScope scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
Local<ObjectTemplate> templ = ObjectTemplate::New();
templ->Set(v8_str("AnalyzeStackOfEvalWithSourceURL"),
- v8::FunctionTemplate::New(AnalyzeStackOfEvalWithSourceURL));
+ v8::FunctionTemplate::New(isolate,
+ AnalyzeStackOfEvalWithSourceURL));
LocalContext context(0, templ);
const char *source =
@@ -16959,20 +17076,21 @@
TEST(ScriptIdInStackTrace) {
- v8::HandleScope scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
Local<ObjectTemplate> templ = ObjectTemplate::New();
templ->Set(v8_str("AnalyzeScriptIdInStack"),
- v8::FunctionTemplate::New(AnalyzeScriptIdInStack));
+ v8::FunctionTemplate::New(isolate, AnalyzeScriptIdInStack));
LocalContext context(0, templ);
v8::Handle<v8::String> scriptSource = v8::String::NewFromUtf8(
- CcTest::isolate(),
+ isolate,
"function foo() {\n"
" AnalyzeScriptIdInStack();"
"}\n"
"foo();\n");
v8::ScriptOrigin origin =
- v8::ScriptOrigin(v8::String::NewFromUtf8(CcTest::isolate(), "test"));
+ v8::ScriptOrigin(v8::String::NewFromUtf8(isolate, "test"));
v8::Local<v8::Script> script(v8::Script::Compile(scriptSource, &origin));
script->Run();
for (int i = 0; i < 2; i++) {
@@ -17003,7 +17121,7 @@
Local<ObjectTemplate> templ = ObjectTemplate::New();
templ->Set(v8_str("AnalyzeStackOfInlineScriptWithSourceURL"),
v8::FunctionTemplate::New(
- AnalyzeStackOfInlineScriptWithSourceURL));
+ CcTest::isolate(), AnalyzeStackOfInlineScriptWithSourceURL));
LocalContext context(0, templ);
const char *source =
@@ -17048,7 +17166,7 @@
Local<ObjectTemplate> templ = ObjectTemplate::New();
templ->Set(v8_str("AnalyzeStackOfDynamicScriptWithSourceURL"),
v8::FunctionTemplate::New(
- AnalyzeStackOfDynamicScriptWithSourceURL));
+ CcTest::isolate(), AnalyzeStackOfDynamicScriptWithSourceURL));
LocalContext context(0, templ);
const char *source =
@@ -17222,7 +17340,7 @@
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
Local<v8::FunctionTemplate> fun_templ =
- v8::FunctionTemplate::New(GetStackLimitCallback);
+ v8::FunctionTemplate::New(env->GetIsolate(), GetStackLimitCallback);
Local<Function> fun = fun_templ->GetFunction();
env->Global()->Set(v8_str("get_stack_limit"), fun);
CompileRun("get_stack_limit();");
@@ -17246,7 +17364,7 @@
v8::HandleScope scope(CcTest::isolate());
LocalContext env;
Local<v8::FunctionTemplate> fun_templ =
- v8::FunctionTemplate::New(GetStackLimitCallback);
+ v8::FunctionTemplate::New(CcTest::isolate(), GetStackLimitCallback);
Local<Function> fun = fun_templ->GetFunction();
env->Global()->Set(v8_str("get_stack_limit"), fun);
CompileRun("get_stack_limit();");
@@ -17547,11 +17665,12 @@
// Test that an exception can be propagated down through a spaghetti
// stack using ReThrow.
THREADED_TEST(SpaghettiStackReThrow) {
- v8::HandleScope scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
LocalContext context;
context->Global()->Set(
- v8::String::NewFromUtf8(CcTest::isolate(), "s"),
- v8::FunctionTemplate::New(SpaghettiIncident)->GetFunction());
+ v8::String::NewFromUtf8(isolate, "s"),
+ v8::FunctionTemplate::New(isolate, SpaghettiIncident)->GetFunction());
v8::TryCatch try_catch;
CompileRun(
"var i = 0;"
@@ -19232,15 +19351,16 @@
THREADED_TEST(CreationContext) {
- HandleScope handle_scope(CcTest::isolate());
- Handle<Context> context1 = Context::New(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ HandleScope handle_scope(isolate);
+ Handle<Context> context1 = Context::New(isolate);
InstallContextId(context1, 1);
- Handle<Context> context2 = Context::New(CcTest::isolate());
+ Handle<Context> context2 = Context::New(isolate);
InstallContextId(context2, 2);
- Handle<Context> context3 = Context::New(CcTest::isolate());
+ Handle<Context> context3 = Context::New(isolate);
InstallContextId(context3, 3);
- Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New();
+ Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(isolate);
Local<Object> object1;
Local<Function> func1;
@@ -19560,8 +19680,10 @@
THREADED_TEST(CallAPIFunctionOnNonObject) {
LocalContext context;
- v8::HandleScope scope(context->GetIsolate());
- Handle<FunctionTemplate> templ = v8::FunctionTemplate::New(NonObjectThis);
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope scope(isolate);
+ Handle<FunctionTemplate> templ =
+ v8::FunctionTemplate::New(isolate, NonObjectThis);
Handle<Function> function = templ->GetFunction();
context->Global()->Set(v8_str("f"), function);
TryCatch try_catch;
@@ -19647,11 +19769,12 @@
IndexedSecurityTestCallback);
// Templates for objects with hidden prototypes and possibly security check.
- Local<FunctionTemplate> hidden_proto_template = v8::FunctionTemplate::New();
+ Local<FunctionTemplate> hidden_proto_template =
+ v8::FunctionTemplate::New(isolate);
hidden_proto_template->SetHiddenPrototype(true);
Local<FunctionTemplate> protected_hidden_proto_template =
- v8::FunctionTemplate::New();
+ v8::FunctionTemplate::New(isolate);
protected_hidden_proto_template->InstanceTemplate()->SetAccessCheckCallbacks(
BlockProtoNamedSecurityTestCallback,
IndexedSecurityTestCallback);
@@ -19727,7 +19850,7 @@
THREADED_TEST(Regress125988) {
v8::HandleScope scope(CcTest::isolate());
- Handle<FunctionTemplate> intercept = FunctionTemplate::New();
+ Handle<FunctionTemplate> intercept = FunctionTemplate::New(CcTest::isolate());
AddInterceptor(intercept, EmptyInterceptorGetter, EmptyInterceptorSetter);
LocalContext env;
env->Global()->Set(v8_str("Intercept"), intercept->GetFunction());
@@ -19889,7 +20012,7 @@
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::Handle<v8::FunctionTemplate> recursive_runtime =
- v8::FunctionTemplate::New(RecursiveCall);
+ v8::FunctionTemplate::New(env->GetIsolate(), RecursiveCall);
env->Global()->Set(v8_str("recursion"),
recursive_runtime->GetFunction());
// Adding the same callback a second time has no effect.
@@ -20186,7 +20309,7 @@
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- Local<FunctionTemplate> templ = FunctionTemplate::New();
+ Local<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate());
Local<ObjectTemplate> inst = templ->InstanceTemplate();
inst->SetAccessor(v8_str("foo"),
InstanceCheckedGetter, InstanceCheckedSetter,
@@ -20214,7 +20337,7 @@
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- Local<FunctionTemplate> templ = FunctionTemplate::New();
+ Local<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate());
Local<ObjectTemplate> inst = templ->InstanceTemplate();
AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter);
inst->SetAccessor(v8_str("foo"),
@@ -20243,7 +20366,7 @@
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- Local<FunctionTemplate> templ = FunctionTemplate::New();
+ Local<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate());
Local<ObjectTemplate> proto = templ->PrototypeTemplate();
proto->SetAccessor(v8_str("foo"),
InstanceCheckedGetter, InstanceCheckedSetter,
@@ -20476,7 +20599,7 @@
THREADED_TEST(Regress149912) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- Handle<FunctionTemplate> templ = FunctionTemplate::New();
+ Handle<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate());
AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter);
context->Global()->Set(v8_str("Bug"), templ->GetFunction());
CompileRun("Number.prototype.__proto__ = new Bug; var x = 0; x.foo();");
@@ -20521,8 +20644,10 @@
THREADED_TEST(Regress260106) {
LocalContext context;
- v8::HandleScope scope(context->GetIsolate());
- Local<FunctionTemplate> templ = FunctionTemplate::New(DummyCallHandler);
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope scope(isolate);
+ Local<FunctionTemplate> templ = FunctionTemplate::New(isolate,
+ DummyCallHandler);
CompileRun("for (var i = 0; i < 128; i++) Object.prototype[i] = 0;");
Local<Function> function = templ->GetFunction();
CHECK(!function.IsEmpty());
@@ -20654,7 +20779,7 @@
if (i == 1) {
// Install a toJSON function on the second run.
v8::Handle<v8::FunctionTemplate> toJSON =
- v8::FunctionTemplate::New(UnreachableCallback);
+ v8::FunctionTemplate::New(CcTest::isolate(), UnreachableCallback);
global0->Set(v8_str("toJSON"), toJSON->GetFunction());
}
@@ -20753,11 +20878,11 @@
context1->Global()->Set(v8_str("other"), global0);
v8::Handle<v8::FunctionTemplate> catcher_fun =
- v8::FunctionTemplate::New(CatcherCallback);
+ v8::FunctionTemplate::New(CcTest::isolate(), CatcherCallback);
context1->Global()->Set(v8_str("catcher"), catcher_fun->GetFunction());
v8::Handle<v8::FunctionTemplate> has_own_property_fun =
- v8::FunctionTemplate::New(HasOwnPropertyCallback);
+ v8::FunctionTemplate::New(CcTest::isolate(), HasOwnPropertyCallback);
context1->Global()->Set(v8_str("has_own_property"),
has_own_property_fun->GetFunction());
@@ -20796,7 +20921,7 @@
i::FLAG_allow_natives_syntax = true;
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
- Handle<FunctionTemplate> templ = FunctionTemplate::New();
+ Handle<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate());
AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter);
context->Global()->Set(v8_str("Bug"), templ->GetFunction());
CompileRun("\"use strict\"; var o = new Bug;"
@@ -20811,7 +20936,7 @@
THREADED_TEST(CrankshaftInterceptorSetter) {
i::FLAG_allow_natives_syntax = true;
v8::HandleScope scope(CcTest::isolate());
- Handle<FunctionTemplate> templ = FunctionTemplate::New();
+ Handle<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate());
AddInterceptor(templ, InterceptorGetter, InterceptorSetter);
LocalContext env;
env->Global()->Set(v8_str("Obj"), templ->GetFunction());
@@ -20837,7 +20962,7 @@
THREADED_TEST(CrankshaftInterceptorGetter) {
i::FLAG_allow_natives_syntax = true;
v8::HandleScope scope(CcTest::isolate());
- Handle<FunctionTemplate> templ = FunctionTemplate::New();
+ Handle<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate());
AddInterceptor(templ, InterceptorGetter, InterceptorSetter);
LocalContext env;
env->Global()->Set(v8_str("Obj"), templ->GetFunction());
@@ -20860,7 +20985,7 @@
THREADED_TEST(CrankshaftInterceptorFieldRead) {
i::FLAG_allow_natives_syntax = true;
v8::HandleScope scope(CcTest::isolate());
- Handle<FunctionTemplate> templ = FunctionTemplate::New();
+ Handle<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate());
AddInterceptor(templ, InterceptorGetter, InterceptorSetter);
LocalContext env;
env->Global()->Set(v8_str("Obj"), templ->GetFunction());
@@ -20880,7 +21005,7 @@
THREADED_TEST(CrankshaftInterceptorFieldWrite) {
i::FLAG_allow_natives_syntax = true;
v8::HandleScope scope(CcTest::isolate());
- Handle<FunctionTemplate> templ = FunctionTemplate::New();
+ Handle<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate());
AddInterceptor(templ, InterceptorGetter, InterceptorSetter);
LocalContext env;
env->Global()->Set(v8_str("Obj"), templ->GetFunction());
diff --git a/test/cctest/test-assembler-ia32.cc b/test/cctest/test-assembler-ia32.cc
index 9c3e6fb..e6abd3d 100644
--- a/test/cctest/test-assembler-ia32.cc
+++ b/test/cctest/test-assembler-ia32.cc
@@ -535,7 +535,8 @@
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
- global_template->Set(v8_str("do_sse2"), v8::FunctionTemplate::New(DoSSE2));
+ global_template->Set(v8_str("do_sse2"),
+ v8::FunctionTemplate::New(isolate, DoSSE2));
LocalContext env(NULL, global_template);
CompileRun(
diff --git a/test/cctest/test-assembler-x64.cc b/test/cctest/test-assembler-x64.cc
index d33da34..473c74d 100644
--- a/test/cctest/test-assembler-x64.cc
+++ b/test/cctest/test-assembler-x64.cc
@@ -615,7 +615,8 @@
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
- global_template->Set(v8_str("do_sse2"), v8::FunctionTemplate::New(DoSSE2));
+ global_template->Set(v8_str("do_sse2"),
+ v8::FunctionTemplate::New(isolate, DoSSE2));
LocalContext env(NULL, global_template);
CompileRun(
diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc
index a0836c3..4bedbb9 100644
--- a/test/cctest/test-compiler.cc
+++ b/test/cctest/test-compiler.cc
@@ -60,7 +60,7 @@
v8::Handle<v8::FunctionTemplate> PrintExtension::GetNativeFunctionTemplate(
v8::Isolate* isolate,
v8::Handle<v8::String> str) {
- return v8::FunctionTemplate::New(PrintExtension::Print);
+ return v8::FunctionTemplate::New(isolate, PrintExtension::Print);
}
diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc
index 6703ada..ab4dd70 100644
--- a/test/cctest/test-cpu-profiler.cc
+++ b/test/cctest/test-cpu-profiler.cc
@@ -31,6 +31,7 @@
#include "cpu-profiler-inl.h"
#include "cctest.h"
#include "platform.h"
+#include "profiler-extension.h"
#include "smart-pointers.h"
#include "utils.h"
#include "../include/v8-profiler.h"
@@ -138,7 +139,7 @@
i::Code* args4_code = CreateCode(&env);
CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap());
- profiles->StartProfiling("", 1, false);
+ profiles->StartProfiling("", false);
ProfileGenerator generator(profiles);
SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor(
&generator, NULL, TimeDelta::FromMicroseconds(100)));
@@ -200,7 +201,7 @@
i::Code* frame3_code = CreateCode(&env);
CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap());
- profiles->StartProfiling("", 1, false);
+ profiles->StartProfiling("", false);
ProfileGenerator generator(profiles);
SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor(
&generator, NULL, TimeDelta::FromMicroseconds(100)));
@@ -269,7 +270,7 @@
i::Code* code = CreateCode(&env);
CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap());
- profiles->StartProfiling("", 1, false);
+ profiles->StartProfiling("", false);
ProfileGenerator generator(profiles);
SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor(
&generator, NULL, TimeDelta::FromMicroseconds(100)));
@@ -332,16 +333,17 @@
}
-static const v8::CpuProfile* FindCpuProfile(v8::CpuProfiler* profiler,
- unsigned uid) {
- int length = profiler->GetProfileCount();
+static bool FindCpuProfile(v8::CpuProfiler* v8profiler,
+ const v8::CpuProfile* v8profile) {
+ i::CpuProfiler* profiler = reinterpret_cast<i::CpuProfiler*>(v8profiler);
+ const i::CpuProfile* profile =
+ reinterpret_cast<const i::CpuProfile*>(v8profile);
+ int length = profiler->GetProfilesCount();
for (int i = 0; i < length; i++) {
- const v8::CpuProfile* profile = profiler->GetCpuProfile(i);
- if (profile->GetUid() == uid) {
- return profile;
- }
+ if (profile == profiler->GetProfile(i))
+ return true;
}
- return NULL;
+ return false;
}
@@ -349,46 +351,38 @@
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
+ i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(cpu_profiler);
- CHECK_EQ(0, cpu_profiler->GetProfileCount());
+ CHECK_EQ(0, iprofiler->GetProfilesCount());
v8::Local<v8::String> name1 = v8::String::NewFromUtf8(env->GetIsolate(), "1");
cpu_profiler->StartCpuProfiling(name1);
const v8::CpuProfile* p1 = cpu_profiler->StopCpuProfiling(name1);
CHECK_NE(NULL, p1);
- CHECK_EQ(1, cpu_profiler->GetProfileCount());
- unsigned uid1 = p1->GetUid();
- CHECK_EQ(p1, FindCpuProfile(cpu_profiler, uid1));
+ CHECK_EQ(1, iprofiler->GetProfilesCount());
+ CHECK(FindCpuProfile(cpu_profiler, p1));
const_cast<v8::CpuProfile*>(p1)->Delete();
- CHECK_EQ(0, cpu_profiler->GetProfileCount());
- CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1));
+ CHECK_EQ(0, iprofiler->GetProfilesCount());
v8::Local<v8::String> name2 = v8::String::NewFromUtf8(env->GetIsolate(), "2");
cpu_profiler->StartCpuProfiling(name2);
const v8::CpuProfile* p2 = cpu_profiler->StopCpuProfiling(name2);
CHECK_NE(NULL, p2);
- CHECK_EQ(1, cpu_profiler->GetProfileCount());
- unsigned uid2 = p2->GetUid();
- CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
- CHECK_EQ(p2, FindCpuProfile(cpu_profiler, uid2));
- CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1));
+ CHECK_EQ(1, iprofiler->GetProfilesCount());
+ CHECK(FindCpuProfile(cpu_profiler, p2));
v8::Local<v8::String> name3 = v8::String::NewFromUtf8(env->GetIsolate(), "3");
cpu_profiler->StartCpuProfiling(name3);
const v8::CpuProfile* p3 = cpu_profiler->StopCpuProfiling(name3);
CHECK_NE(NULL, p3);
- CHECK_EQ(2, cpu_profiler->GetProfileCount());
- unsigned uid3 = p3->GetUid();
- CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3));
- CHECK_EQ(p3, FindCpuProfile(cpu_profiler, uid3));
- CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1));
+ CHECK_EQ(2, iprofiler->GetProfilesCount());
+ CHECK_NE(p2, p3);
+ CHECK(FindCpuProfile(cpu_profiler, p3));
+ CHECK(FindCpuProfile(cpu_profiler, p2));
const_cast<v8::CpuProfile*>(p2)->Delete();
- CHECK_EQ(1, cpu_profiler->GetProfileCount());
- CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid2));
- CHECK_EQ(p3, FindCpuProfile(cpu_profiler, uid3));
+ CHECK_EQ(1, iprofiler->GetProfilesCount());
+ CHECK(!FindCpuProfile(cpu_profiler, p2));
+ CHECK(FindCpuProfile(cpu_profiler, p3));
const_cast<v8::CpuProfile*>(p3)->Delete();
- CHECK_EQ(0, cpu_profiler->GetProfileCount());
- CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid3));
- CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid2));
- CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1));
+ CHECK_EQ(0, iprofiler->GetProfilesCount());
}
@@ -589,8 +583,7 @@
CheckSimpleBranch(env->GetIsolate(), fooNode, delayBranch,
ARRAY_SIZE(delayBranch));
- v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
- cpu_profiler->DeleteAllCpuProfiles();
+ const_cast<v8::CpuProfile*>(profile)->Delete();
}
@@ -657,8 +650,7 @@
}
}
- v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
- cpu_profiler->DeleteAllCpuProfiles();
+ const_cast<v8::CpuProfile*>(profile)->Delete();
}
@@ -724,29 +716,30 @@
// code.
TEST(NativeAccessorUninitializedIC) {
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
-
- v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New();
+ v8::Local<v8::FunctionTemplate> func_template =
+ v8::FunctionTemplate::New(isolate);
v8::Local<v8::ObjectTemplate> instance_template =
func_template->InstanceTemplate();
TestApiCallbacks accessors(100);
v8::Local<v8::External> data =
- v8::External::New(env->GetIsolate(), &accessors);
+ v8::External::New(isolate, &accessors);
instance_template->SetAccessor(
- v8::String::NewFromUtf8(env->GetIsolate(), "foo"),
+ v8::String::NewFromUtf8(isolate, "foo"),
&TestApiCallbacks::Getter, &TestApiCallbacks::Setter, data);
v8::Local<v8::Function> func = func_template->GetFunction();
v8::Local<v8::Object> instance = func->NewInstance();
- env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"),
+ env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"),
instance);
v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), native_accessor_test_source))
+ v8::String::NewFromUtf8(isolate, native_accessor_test_source))
->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
+ env->Global()->Get(v8::String::NewFromUtf8(isolate, "start")));
int32_t repeat_count = 1;
v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) };
@@ -755,12 +748,11 @@
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
const v8::CpuProfileNode* startNode =
- GetChild(env->GetIsolate(), root, "start");
- GetChild(env->GetIsolate(), startNode, "get foo");
- GetChild(env->GetIsolate(), startNode, "set foo");
+ GetChild(isolate, root, "start");
+ GetChild(isolate, startNode, "get foo");
+ GetChild(isolate, startNode, "set foo");
- v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
- cpu_profiler->DeleteAllCpuProfiles();
+ const_cast<v8::CpuProfile*>(profile)->Delete();
}
@@ -769,29 +761,30 @@
// hot and to trigger optimizations.
TEST(NativeAccessorMonomorphicIC) {
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
-
- v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New();
+ v8::Local<v8::FunctionTemplate> func_template =
+ v8::FunctionTemplate::New(isolate);
v8::Local<v8::ObjectTemplate> instance_template =
func_template->InstanceTemplate();
TestApiCallbacks accessors(1);
v8::Local<v8::External> data =
- v8::External::New(env->GetIsolate(), &accessors);
+ v8::External::New(isolate, &accessors);
instance_template->SetAccessor(
- v8::String::NewFromUtf8(env->GetIsolate(), "foo"),
+ v8::String::NewFromUtf8(isolate, "foo"),
&TestApiCallbacks::Getter, &TestApiCallbacks::Setter, data);
v8::Local<v8::Function> func = func_template->GetFunction();
v8::Local<v8::Object> instance = func->NewInstance();
- env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"),
+ env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"),
instance);
v8::Script::Compile(
- v8::String::NewFromUtf8(env->GetIsolate(), native_accessor_test_source))
+ v8::String::NewFromUtf8(isolate, native_accessor_test_source))
->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
+ env->Global()->Get(v8::String::NewFromUtf8(isolate, "start")));
{
// Make sure accessors ICs are in monomorphic state before starting
@@ -810,12 +803,11 @@
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
const v8::CpuProfileNode* startNode =
- GetChild(env->GetIsolate(), root, "start");
- GetChild(env->GetIsolate(), startNode, "get foo");
- GetChild(env->GetIsolate(), startNode, "set foo");
+ GetChild(isolate, root, "start");
+ GetChild(isolate, startNode, "get foo");
+ GetChild(isolate, startNode, "set foo");
- v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
- cpu_profiler->DeleteAllCpuProfiles();
+ const_cast<v8::CpuProfile*>(profile)->Delete();
}
@@ -828,32 +820,35 @@
TEST(NativeMethodUninitializedIC) {
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
TestApiCallbacks callbacks(100);
v8::Local<v8::External> data =
- v8::External::New(env->GetIsolate(), &callbacks);
+ v8::External::New(isolate, &callbacks);
- v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New();
+ v8::Local<v8::FunctionTemplate> func_template =
+ v8::FunctionTemplate::New(isolate);
func_template->SetClassName(
- v8::String::NewFromUtf8(env->GetIsolate(), "Test_InstanceCostructor"));
+ v8::String::NewFromUtf8(isolate, "Test_InstanceCostructor"));
v8::Local<v8::ObjectTemplate> proto_template =
func_template->PrototypeTemplate();
v8::Local<v8::Signature> signature =
- v8::Signature::New(env->GetIsolate(), func_template);
- proto_template->Set(v8::String::NewFromUtf8(env->GetIsolate(), "fooMethod"),
- v8::FunctionTemplate::New(&TestApiCallbacks::Callback,
+ v8::Signature::New(isolate, func_template);
+ proto_template->Set(v8::String::NewFromUtf8(isolate, "fooMethod"),
+ v8::FunctionTemplate::New(isolate,
+ &TestApiCallbacks::Callback,
data, signature, 0));
v8::Local<v8::Function> func = func_template->GetFunction();
v8::Local<v8::Object> instance = func->NewInstance();
- env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"),
+ env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"),
instance);
v8::Script::Compile(v8::String::NewFromUtf8(
- env->GetIsolate(), native_method_test_source))->Run();
+ isolate, native_method_test_source))->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
+ env->Global()->Get(v8::String::NewFromUtf8(isolate, "start")));
int32_t repeat_count = 1;
v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) };
@@ -862,42 +857,44 @@
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
const v8::CpuProfileNode* startNode =
- GetChild(env->GetIsolate(), root, "start");
- GetChild(env->GetIsolate(), startNode, "fooMethod");
+ GetChild(isolate, root, "start");
+ GetChild(isolate, startNode, "fooMethod");
- v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
- cpu_profiler->DeleteAllCpuProfiles();
+ const_cast<v8::CpuProfile*>(profile)->Delete();
}
TEST(NativeMethodMonomorphicIC) {
LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
TestApiCallbacks callbacks(1);
v8::Local<v8::External> data =
- v8::External::New(env->GetIsolate(), &callbacks);
+ v8::External::New(isolate, &callbacks);
- v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New();
+ v8::Local<v8::FunctionTemplate> func_template =
+ v8::FunctionTemplate::New(isolate);
func_template->SetClassName(
- v8::String::NewFromUtf8(env->GetIsolate(), "Test_InstanceCostructor"));
+ v8::String::NewFromUtf8(isolate, "Test_InstanceCostructor"));
v8::Local<v8::ObjectTemplate> proto_template =
func_template->PrototypeTemplate();
v8::Local<v8::Signature> signature =
- v8::Signature::New(env->GetIsolate(), func_template);
- proto_template->Set(v8::String::NewFromUtf8(env->GetIsolate(), "fooMethod"),
- v8::FunctionTemplate::New(&TestApiCallbacks::Callback,
+ v8::Signature::New(isolate, func_template);
+ proto_template->Set(v8::String::NewFromUtf8(isolate, "fooMethod"),
+ v8::FunctionTemplate::New(isolate,
+ &TestApiCallbacks::Callback,
data, signature, 0));
v8::Local<v8::Function> func = func_template->GetFunction();
v8::Local<v8::Object> instance = func->NewInstance();
- env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"),
+ env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"),
instance);
v8::Script::Compile(v8::String::NewFromUtf8(
- env->GetIsolate(), native_method_test_source))->Run();
+ isolate, native_method_test_source))->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
+ env->Global()->Get(v8::String::NewFromUtf8(isolate, "start")));
{
// Make sure method ICs are in monomorphic state before starting
// profiling.
@@ -914,13 +911,12 @@
RunProfiler(env, function, args, ARRAY_SIZE(args), 100);
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
- GetChild(env->GetIsolate(), root, "start");
+ GetChild(isolate, root, "start");
const v8::CpuProfileNode* startNode =
- GetChild(env->GetIsolate(), root, "start");
- GetChild(env->GetIsolate(), startNode, "fooMethod");
+ GetChild(isolate, root, "start");
+ GetChild(isolate, startNode, "fooMethod");
- v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
- cpu_profiler->DeleteAllCpuProfiles();
+ const_cast<v8::CpuProfile*>(profile)->Delete();
}
@@ -967,8 +963,7 @@
GetChild(env->GetIsolate(), root, "start");
GetChild(env->GetIsolate(), startNode, "foo");
- v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
- cpu_profiler->DeleteAllCpuProfiles();
+ const_cast<v8::CpuProfile*>(profile)->Delete();
}
@@ -1049,8 +1044,7 @@
CheckChildrenNames(unresolvedNode, names);
}
- v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
- cpu_profiler->DeleteAllCpuProfiles();
+ const_cast<v8::CpuProfile*>(profile)->Delete();
}
@@ -1137,8 +1131,7 @@
}
}
- v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
- cpu_profiler->DeleteAllCpuProfiles();
+ const_cast<v8::CpuProfile*>(profile)->Delete();
}
@@ -1186,7 +1179,7 @@
v8::HandleScope scope(env->GetIsolate());
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
- CallJsFunction);
+ env->GetIsolate(), CallJsFunction);
v8::Local<v8::Function> func = func_template->GetFunction();
func->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"));
env->Global()->Set(
@@ -1226,8 +1219,7 @@
CHECK_EQ(1, barNode->GetChildrenCount());
GetChild(env->GetIsolate(), barNode, "foo");
- v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
- cpu_profiler->DeleteAllCpuProfiles();
+ const_cast<v8::CpuProfile*>(profile)->Delete();
}
@@ -1270,7 +1262,7 @@
v8::HandleScope scope(env->GetIsolate());
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
- CallJsFunction);
+ env->GetIsolate(), CallJsFunction);
v8::Local<v8::Function> func = func_template->GetFunction();
func->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"));
env->Global()->Set(
@@ -1309,8 +1301,7 @@
CHECK_EQ(1, barNode->GetChildrenCount());
GetChild(env->GetIsolate(), barNode, "foo");
- v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
- cpu_profiler->DeleteAllCpuProfiles();
+ const_cast<v8::CpuProfile*>(profile)->Delete();
}
@@ -1358,14 +1349,14 @@
v8::HandleScope scope(env->GetIsolate());
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
- CallJsFunction);
+ env->GetIsolate(), CallJsFunction);
v8::Local<v8::Function> func1 = func_template->GetFunction();
func1->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction1"));
env->Global()->Set(
v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction1"), func1);
v8::Local<v8::Function> func2 = v8::FunctionTemplate::New(
- CallJsFunction2)->GetFunction();
+ env->GetIsolate(), CallJsFunction2)->GetFunction();
func2->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction2"));
env->Global()->Set(
v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction2"), func2);
@@ -1407,8 +1398,7 @@
CHECK_EQ(1, nativeNode2->GetChildrenCount());
GetChild(env->GetIsolate(), nativeNode2, "foo");
- v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
- cpu_profiler->DeleteAllCpuProfiles();
+ const_cast<v8::CpuProfile*>(profile)->Delete();
}
@@ -1465,7 +1455,7 @@
CHECK_EQ(0, idleNode->GetChildrenCount());
CHECK_GE(idleNode->GetHitCount(), 3);
- cpu_profiler->DeleteAllCpuProfiles();
+ const_cast<v8::CpuProfile*>(profile)->Delete();
}
@@ -1489,8 +1479,6 @@
LocalContext env(&config);
v8::HandleScope handleScope(env->GetIsolate());
- v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler();
- CHECK_EQ(0, profiler->GetProfileCount());
v8::Handle<v8::Script> script_a = v8::Script::Compile(
v8::String::NewFromUtf8(
env->GetIsolate(),
@@ -1506,8 +1494,7 @@
"stopProfiling();\n"),
v8::String::NewFromUtf8(env->GetIsolate(), "script_b"));
script_b->Run();
- CHECK_EQ(1, profiler->GetProfileCount());
- const v8::CpuProfile* profile = profiler->GetCpuProfile(0);
+ const v8::CpuProfile* profile = ProfilerExtension::last_profile;
const v8::CpuProfileNode* current = profile->GetTopDownRoot();
reinterpret_cast<ProfileNode*>(
const_cast<v8::CpuProfileNode*>(current))->Print(0);
@@ -1543,27 +1530,28 @@
v8::HandleScope handleScope(isolate);
v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler();
+ i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler);
- CHECK_EQ(0, profiler->GetProfileCount());
+ CHECK_EQ(0, iprofiler->GetProfilesCount());
v8::Handle<v8::String> outer = v8::String::NewFromUtf8(isolate, "outer");
profiler->StartCpuProfiling(outer);
- CHECK_EQ(0, profiler->GetProfileCount());
+ CHECK_EQ(0, iprofiler->GetProfilesCount());
v8::Handle<v8::String> inner = v8::String::NewFromUtf8(isolate, "inner");
profiler->StartCpuProfiling(inner);
- CHECK_EQ(0, profiler->GetProfileCount());
+ CHECK_EQ(0, iprofiler->GetProfilesCount());
const v8::CpuProfile* inner_profile = profiler->StopCpuProfiling(inner);
CHECK(inner_profile);
- CHECK_EQ(1, profiler->GetProfileCount());
+ CHECK_EQ(1, iprofiler->GetProfilesCount());
const_cast<v8::CpuProfile*>(inner_profile)->Delete();
inner_profile = NULL;
- CHECK_EQ(0, profiler->GetProfileCount());
+ CHECK_EQ(0, iprofiler->GetProfilesCount());
const v8::CpuProfile* outer_profile = profiler->StopCpuProfiling(outer);
CHECK(outer_profile);
- CHECK_EQ(1, profiler->GetProfileCount());
+ CHECK_EQ(1, iprofiler->GetProfilesCount());
const_cast<v8::CpuProfile*>(outer_profile)->Delete();
outer_profile = NULL;
- CHECK_EQ(0, profiler->GetProfileCount());
+ CHECK_EQ(0, iprofiler->GetProfilesCount());
}
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index 3cb8400..463fa80 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -4476,33 +4476,34 @@
TEST(HiddenPrototypePropertyMirror) {
// Create a V8 environment with debug access.
DebugLocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
env.ExposeDebug();
- v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New();
- t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "x"),
+ v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
+ t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "x"),
v8::Number::New(0));
- v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
+ v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
t1->SetHiddenPrototype(true);
- t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "y"),
+ t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "y"),
v8::Number::New(1));
- v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New();
+ v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate);
t2->SetHiddenPrototype(true);
- t2->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "z"),
+ t2->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "z"),
v8::Number::New(2));
- v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New();
- t3->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "u"),
+ v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate);
+ t3->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "u"),
v8::Number::New(3));
// Create object and set them on the global object.
v8::Handle<v8::Object> o0 = t0->GetFunction()->NewInstance();
- env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o0"), o0);
+ env->Global()->Set(v8::String::NewFromUtf8(isolate, "o0"), o0);
v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance();
- env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o1"), o1);
+ env->Global()->Set(v8::String::NewFromUtf8(isolate, "o1"), o1);
v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance();
- env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o2"), o2);
+ env->Global()->Set(v8::String::NewFromUtf8(isolate, "o2"), o2);
v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance();
- env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o3"), o3);
+ env->Global()->Set(v8::String::NewFromUtf8(isolate, "o3"), o3);
// Get mirrors for the four objects.
CompileRun(
@@ -4527,7 +4528,7 @@
// Set o1 as prototype for o0. o1 has the hidden prototype flag so all
// properties on o1 should be seen on o0.
- o0->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), o1);
+ o0->Set(v8::String::NewFromUtf8(isolate, "__proto__"), o1);
CHECK_EQ(2, CompileRun(
"o0_mirror.propertyNames().length")->Int32Value());
CHECK_EQ(0, CompileRun(
@@ -4538,7 +4539,7 @@
// Set o2 as prototype for o0 (it will end up after o1 as o1 has the hidden
// prototype flag. o2 also has the hidden prototype flag so all properties
// on o2 should be seen on o0 as well as properties on o1.
- o0->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), o2);
+ o0->Set(v8::String::NewFromUtf8(isolate, "__proto__"), o2);
CHECK_EQ(3, CompileRun(
"o0_mirror.propertyNames().length")->Int32Value());
CHECK_EQ(0, CompileRun(
@@ -4554,7 +4555,7 @@
// from o1 and o2 should still be seen on o0.
// Final prototype chain: o0 -> o1 -> o2 -> o3
// Hidden prototypes: ^^ ^^
- o0->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), o3);
+ o0->Set(v8::String::NewFromUtf8(isolate, "__proto__"), o3);
CHECK_EQ(3, CompileRun(
"o0_mirror.propertyNames().length")->Int32Value());
CHECK_EQ(1, CompileRun(
@@ -4657,18 +4658,19 @@
TEST(NoHiddenProperties) {
// Create a V8 environment with debug access.
DebugLocalContext env;
- v8::HandleScope scope(env->GetIsolate());
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
env.ExposeDebug();
// Create an object in the global scope.
const char* source = "var obj = {a: 1};";
- v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), source))
+ v8::Script::Compile(v8::String::NewFromUtf8(isolate, source))
->Run();
v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(
- env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "obj")));
+ env->Global()->Get(v8::String::NewFromUtf8(isolate, "obj")));
// Set a hidden property on the object.
obj->SetHiddenValue(
- v8::String::NewFromUtf8(env->GetIsolate(), "v8::test-debug::a"),
+ v8::String::NewFromUtf8(isolate, "v8::test-debug::a"),
v8::Int32::New(11));
// Get mirror for the object with property getter.
@@ -4685,34 +4687,34 @@
"obj_mirror.property('a').value().value() == 1")->BooleanValue());
// Object created by t0 will become hidden prototype of object 'obj'.
- v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New();
- t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "b"),
+ v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
+ t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "b"),
v8::Number::New(2));
t0->SetHiddenPrototype(true);
- v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
- t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "c"),
+ v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
+ t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "c"),
v8::Number::New(3));
// Create proto objects, add hidden properties to them and set them on
// the global object.
v8::Handle<v8::Object> protoObj = t0->GetFunction()->NewInstance();
protoObj->SetHiddenValue(
- v8::String::NewFromUtf8(env->GetIsolate(), "v8::test-debug::b"),
+ v8::String::NewFromUtf8(isolate, "v8::test-debug::b"),
v8::Int32::New(12));
- env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "protoObj"),
+ env->Global()->Set(v8::String::NewFromUtf8(isolate, "protoObj"),
protoObj);
v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance();
grandProtoObj->SetHiddenValue(
- v8::String::NewFromUtf8(env->GetIsolate(), "v8::test-debug::c"),
+ v8::String::NewFromUtf8(isolate, "v8::test-debug::c"),
v8::Int32::New(13));
env->Global()->Set(
- v8::String::NewFromUtf8(env->GetIsolate(), "grandProtoObj"),
+ v8::String::NewFromUtf8(isolate, "grandProtoObj"),
grandProtoObj);
// Setting prototypes: obj->protoObj->grandProtoObj
- protoObj->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"),
+ protoObj->Set(v8::String::NewFromUtf8(isolate, "__proto__"),
grandProtoObj);
- obj->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), protoObj);
+ obj->Set(v8::String::NewFromUtf8(isolate, "__proto__"), protoObj);
// Get mirror for the object with property getter.
CompileRun("var obj_mirror = debug.MakeMirror(obj);");
@@ -5207,7 +5209,7 @@
v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
global_template->Set(
v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"),
- v8::FunctionTemplate::New(ThreadedAtBarrier1));
+ v8::FunctionTemplate::New(CcTest::isolate(), ThreadedAtBarrier1));
v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(),
NULL,
global_template);
@@ -5568,16 +5570,16 @@
v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
global_template->Set(
v8::String::NewFromUtf8(CcTest::isolate(), "CheckFrameCount"),
- v8::FunctionTemplate::New(CheckFrameCount));
+ v8::FunctionTemplate::New(CcTest::isolate(), CheckFrameCount));
global_template->Set(
v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine"),
- v8::FunctionTemplate::New(CheckSourceLine));
+ v8::FunctionTemplate::New(CcTest::isolate(), CheckSourceLine));
global_template->Set(
v8::String::NewFromUtf8(CcTest::isolate(), "CheckDataParameter"),
- v8::FunctionTemplate::New(CheckDataParameter));
+ v8::FunctionTemplate::New(CcTest::isolate(), CheckDataParameter));
global_template->Set(
v8::String::NewFromUtf8(CcTest::isolate(), "CheckClosure"),
- v8::FunctionTemplate::New(CheckClosure));
+ v8::FunctionTemplate::New(CcTest::isolate(), CheckClosure));
v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(),
NULL,
global_template);
@@ -7427,7 +7429,7 @@
CompileFunction(&env, frame_local_value_source, "frame_local_value");
v8::Handle<v8::FunctionTemplate> schedule_break_template =
- v8::FunctionTemplate::New(ScheduleBreak);
+ v8::FunctionTemplate::New(env->GetIsolate(), ScheduleBreak);
v8::Handle<v8::Function> schedule_break =
schedule_break_template->GetFunction();
env->Global()->Set(v8_str("scheduleBreak"), schedule_break);
diff --git a/test/cctest/test-declarative-accessors.cc b/test/cctest/test-declarative-accessors.cc
index aefd59d..5bc432e 100644
--- a/test/cctest/test-declarative-accessors.cc
+++ b/test/cctest/test-declarative-accessors.cc
@@ -95,7 +95,8 @@
const char* descriptor_name = NULL,
v8::Handle<v8::DeclaredAccessorDescriptor> descriptor =
v8::Handle<v8::DeclaredAccessorDescriptor>()) {
- v8::Local<v8::FunctionTemplate> constructor = v8::FunctionTemplate::New();
+ v8::Local<v8::FunctionTemplate> constructor =
+ v8::FunctionTemplate::New(context->GetIsolate());
v8::Local<v8::ObjectTemplate> obj_template = constructor->InstanceTemplate();
// Setup object template.
if (descriptor_name != NULL && !descriptor.IsEmpty()) {
diff --git a/test/cctest/test-decls.cc b/test/cctest/test-decls.cc
index de0d745..6ae23f2 100644
--- a/test/cctest/test-decls.cc
+++ b/test/cctest/test-decls.cc
@@ -118,7 +118,7 @@
if (is_initialized_) return;
Isolate* isolate = CcTest::isolate();
HandleScope scope(isolate);
- Local<FunctionTemplate> function = FunctionTemplate::New();
+ Local<FunctionTemplate> function = FunctionTemplate::New(isolate);
Local<Value> data = External::New(CcTest::isolate(), this);
GetHolder(function)->SetNamedPropertyHandler(&HandleGet,
&HandleSet,
@@ -634,7 +634,7 @@
class ExistsInHiddenPrototypeContext: public DeclarationContext {
public:
ExistsInHiddenPrototypeContext() {
- hidden_proto_ = FunctionTemplate::New();
+ hidden_proto_ = FunctionTemplate::New(CcTest::isolate());
hidden_proto_->SetHiddenPrototype(true);
}
diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc
index 0a81632..69c97ca 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -1041,6 +1041,49 @@
}
+TEST(HeapObjectIds) {
+ LocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+ v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
+
+ const int kLength = 10;
+ v8::Handle<v8::Object> objects[kLength];
+ v8::SnapshotObjectId ids[kLength];
+
+ heap_profiler->StartTrackingHeapObjects(false);
+
+ for (int i = 0; i < kLength; i++) {
+ objects[i] = v8::Object::New(isolate);
+ }
+ GetHeapStatsUpdate(heap_profiler);
+
+ for (int i = 0; i < kLength; i++) {
+ v8::SnapshotObjectId id = heap_profiler->GetObjectId(objects[i]);
+ CHECK_NE(v8::HeapProfiler::kUnknownObjectId, static_cast<int>(id));
+ ids[i] = id;
+ }
+
+ heap_profiler->StopTrackingHeapObjects();
+ CcTest::heap()->CollectAllAvailableGarbage();
+
+ for (int i = 0; i < kLength; i++) {
+ v8::SnapshotObjectId id = heap_profiler->GetObjectId(objects[i]);
+ CHECK_EQ(static_cast<int>(ids[i]), static_cast<int>(id));
+ v8::Handle<v8::Value> obj = heap_profiler->FindObjectById(ids[i]);
+ CHECK_EQ(objects[i], obj);
+ }
+
+ heap_profiler->ClearObjectIds();
+ for (int i = 0; i < kLength; i++) {
+ v8::SnapshotObjectId id = heap_profiler->GetObjectId(objects[i]);
+ CHECK_EQ(v8::HeapProfiler::kUnknownObjectId, static_cast<int>(id));
+ v8::Handle<v8::Value> obj = heap_profiler->FindObjectById(ids[i]);
+ CHECK(obj.IsEmpty());
+ }
+}
+
+
static void CheckChildrenIds(const v8::HeapSnapshot* snapshot,
const v8::HeapGraphNode* node,
int level, int max_level) {
@@ -2044,6 +2087,7 @@
v8::Handle<v8::String> name) {
if (name->Equals(v8::String::NewFromUtf8(isolate, "findUntrackedObjects"))) {
return v8::FunctionTemplate::New(
+ isolate,
HeapProfilerExtension::FindUntrackedObjects);
} else {
CHECK(false);
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 8a8df29..3b73ba7 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
CHECK(WeakPointerCleared);
CHECK(!GlobalHandles::IsNearDeath(h1.location()));
- global_handles->Destroy(h1.location());
+ GlobalHandles::Destroy(h1.location());
}
@@ -507,9 +512,10 @@
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();
diff --git a/test/cctest/test-log-stack-tracer.cc b/test/cctest/test-log-stack-tracer.cc
index 7d60c2a..c3752ff 100644
--- a/test/cctest/test-log-stack-tracer.cc
+++ b/test/cctest/test-log-stack-tracer.cc
@@ -115,14 +115,14 @@
v8::Handle<v8::FunctionTemplate> TraceExtension::GetNativeFunctionTemplate(
v8::Isolate* isolate, v8::Handle<String> name) {
if (name->Equals(String::NewFromUtf8(isolate, "trace"))) {
- return v8::FunctionTemplate::New(TraceExtension::Trace);
+ return v8::FunctionTemplate::New(isolate, TraceExtension::Trace);
} else if (name->Equals(
String::NewFromUtf8(isolate, "js_trace"))) {
- return v8::FunctionTemplate::New(TraceExtension::JSTrace);
+ return v8::FunctionTemplate::New(isolate, TraceExtension::JSTrace);
} else if (name->Equals(String::NewFromUtf8(isolate, "js_entry_sp"))) {
- return v8::FunctionTemplate::New(TraceExtension::JSEntrySP);
+ return v8::FunctionTemplate::New(isolate, TraceExtension::JSEntrySP);
} else if (name->Equals(String::NewFromUtf8(isolate, "js_entry_sp_level2"))) {
- return v8::FunctionTemplate::New(TraceExtension::JSEntrySPLevel2);
+ return v8::FunctionTemplate::New(isolate, TraceExtension::JSEntrySPLevel2);
} else {
CHECK(false);
return v8::Handle<v8::FunctionTemplate>();
@@ -232,7 +232,7 @@
void CreateFramePointerGrabberConstructor(v8::Local<v8::Context> context,
const char* constructor_name) {
Local<v8::FunctionTemplate> constructor_template =
- v8::FunctionTemplate::New(construct_call);
+ v8::FunctionTemplate::New(context->GetIsolate(), construct_call);
constructor_template->SetClassName(v8_str("FPGrabber"));
Local<Function> fun = constructor_template->GetFunction();
context->Global()->Set(v8_str(constructor_name), fun);
diff --git a/test/cctest/test-log.cc b/test/cctest/test-log.cc
index 6c91f72..d80e4e8 100644
--- a/test/cctest/test-log.cc
+++ b/test/cctest/test-log.cc
@@ -329,18 +329,20 @@
TEST(LogCallbacks) {
+ v8::Isolate* isolate = CcTest::isolate();
ScopedLoggerInitializer initialize_logger;
Logger* logger = initialize_logger.logger();
v8::Local<v8::FunctionTemplate> obj =
- v8::Local<v8::FunctionTemplate>::New(CcTest::isolate(),
- v8::FunctionTemplate::New());
+ v8::Local<v8::FunctionTemplate>::New(isolate,
+ v8::FunctionTemplate::New(isolate));
obj->SetClassName(v8_str("Obj"));
v8::Handle<v8::ObjectTemplate> proto = obj->PrototypeTemplate();
v8::Local<v8::Signature> signature =
- v8::Signature::New(CcTest::isolate(), obj);
+ v8::Signature::New(isolate, obj);
proto->Set(v8_str("method1"),
- v8::FunctionTemplate::New(ObjMethod1,
+ v8::FunctionTemplate::New(isolate,
+ ObjMethod1,
v8::Handle<v8::Value>(),
signature),
static_cast<v8::PropertyAttribute>(v8::DontDelete));
@@ -379,12 +381,13 @@
TEST(LogAccessorCallbacks) {
+ v8::Isolate* isolate = CcTest::isolate();
ScopedLoggerInitializer initialize_logger;
Logger* logger = initialize_logger.logger();
v8::Local<v8::FunctionTemplate> obj =
- v8::Local<v8::FunctionTemplate>::New(CcTest::isolate(),
- v8::FunctionTemplate::New());
+ v8::Local<v8::FunctionTemplate>::New(isolate,
+ v8::FunctionTemplate::New(isolate));
obj->SetClassName(v8_str("Obj"));
v8::Handle<v8::ObjectTemplate> inst = obj->InstanceTemplate();
inst->SetAccessor(v8_str("prop1"), Prop1Getter, Prop1Setter);
diff --git a/test/cctest/test-mark-compact.cc b/test/cctest/test-mark-compact.cc
index a463432..1d8a070 100644
--- a/test/cctest/test-mark-compact.cc
+++ b/test/cctest/test-mark-compact.cc
@@ -35,6 +35,7 @@
#include <errno.h>
#endif
+#include <utility>
#include "v8.h"
@@ -245,12 +246,14 @@
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 @@
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 @@
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 @@
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 @@
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);
diff --git a/test/cctest/test-object-observe.cc b/test/cctest/test-object-observe.cc
index b4e7c69..26afa51 100644
--- a/test/cctest/test-object-observe.cc
+++ b/test/cctest/test-object-observe.cc
@@ -379,7 +379,7 @@
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
LocalContext context(isolate.GetIsolate());
- Handle<FunctionTemplate> tmpl = FunctionTemplate::New();
+ Handle<FunctionTemplate> tmpl = FunctionTemplate::New(isolate.GetIsolate());
tmpl->SetHiddenPrototype(true);
tmpl->InstanceTemplate()->Set(
String::NewFromUtf8(isolate.GetIsolate(), "foo"), Number::New(75));
diff --git a/test/cctest/test-platform.cc b/test/cctest/test-platform.cc
index 36ad487..0699d7a 100644
--- a/test/cctest/test-platform.cc
+++ b/test/cctest/test-platform.cc
@@ -74,7 +74,7 @@
v8::HandleScope handle_scope(isolate);
v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
global_template->Set(v8_str("get_stack_pointer"),
- v8::FunctionTemplate::New(GetStackPointer));
+ v8::FunctionTemplate::New(isolate, GetStackPointer));
LocalContext env(NULL, global_template);
CompileRun(
diff --git a/test/cctest/test-profile-generator.cc b/test/cctest/test-profile-generator.cc
index 54791e2..0cd30ef 100644
--- a/test/cctest/test-profile-generator.cc
+++ b/test/cctest/test-profile-generator.cc
@@ -29,6 +29,7 @@
#include "v8.h"
#include "profile-generator-inl.h"
+#include "profiler-extension.h"
#include "cctest.h"
#include "cpu-profiler.h"
#include "../include/v8-profiler.h"
@@ -400,7 +401,7 @@
TEST(RecordTickSample) {
TestSetup test_setup;
CpuProfilesCollection profiles(CcTest::heap());
- profiles.StartProfiling("", 1, false);
+ profiles.StartProfiling("", false);
ProfileGenerator generator(&profiles);
CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa");
CodeEntry* entry2 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb");
@@ -466,7 +467,7 @@
TEST(SampleIds) {
TestSetup test_setup;
CpuProfilesCollection profiles(CcTest::heap());
- profiles.StartProfiling("", 1, true);
+ profiles.StartProfiling("", true);
ProfileGenerator generator(&profiles);
CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa");
CodeEntry* entry2 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb");
@@ -514,7 +515,7 @@
TEST(NoSamples) {
TestSetup test_setup;
CpuProfilesCollection profiles(CcTest::heap());
- profiles.StartProfiling("", 1, false);
+ profiles.StartProfiling("", false);
ProfileGenerator generator(&profiles);
CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa");
generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200);
@@ -536,63 +537,6 @@
}
-// --- P r o f i l e r E x t e n s i o n ---
-
-class ProfilerExtension : public v8::Extension {
- public:
- ProfilerExtension() : v8::Extension("v8/profiler", kSource) { }
- virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate(
- v8::Isolate* isolate,
- v8::Handle<v8::String> name);
- static void StartProfiling(const v8::FunctionCallbackInfo<v8::Value>& args);
- static void StopProfiling(const v8::FunctionCallbackInfo<v8::Value>& args);
- private:
- static const char* kSource;
-};
-
-
-const char* ProfilerExtension::kSource =
- "native function startProfiling();"
- "native function stopProfiling();";
-
-v8::Handle<v8::FunctionTemplate> ProfilerExtension::GetNativeFunctionTemplate(
- v8::Isolate* isolate, v8::Handle<v8::String> name) {
- if (name->Equals(v8::String::NewFromUtf8(isolate, "startProfiling"))) {
- return v8::FunctionTemplate::New(ProfilerExtension::StartProfiling);
- } else if (name->Equals(v8::String::NewFromUtf8(isolate, "stopProfiling"))) {
- return v8::FunctionTemplate::New(ProfilerExtension::StopProfiling);
- } else {
- CHECK(false);
- return v8::Handle<v8::FunctionTemplate>();
- }
-}
-
-
-void ProfilerExtension::StartProfiling(
- const v8::FunctionCallbackInfo<v8::Value>& args) {
- v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler();
- if (args.Length() > 0)
- cpu_profiler->StartCpuProfiling(args[0].As<v8::String>());
- else
- cpu_profiler->StartCpuProfiling(
- v8::String::NewFromUtf8(args.GetIsolate(), ""));
-}
-
-
-void ProfilerExtension::StopProfiling(
- const v8::FunctionCallbackInfo<v8::Value>& args) {
- v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler();
- if (args.Length() > 0)
- cpu_profiler->StopCpuProfiling(args[0].As<v8::String>());
- else
- cpu_profiler->StopCpuProfiling(
- v8::String::NewFromUtf8(args.GetIsolate(), ""));
-}
-
-
-static ProfilerExtension kProfilerExtension;
-v8::DeclareExtension kProfilerExtensionDeclaration(&kProfilerExtension);
-
static const ProfileNode* PickChild(const ProfileNode* parent,
const char* name) {
for (int i = 0; i < parent->children()->length(); ++i) {
@@ -661,12 +605,10 @@
for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) {
i::Vector<char> title = i::Vector<char>::New(16);
i::OS::SNPrintF(title, "%d", i);
- // UID must be > 0.
- CHECK(collection.StartProfiling(title.start(), i + 1, false));
+ CHECK(collection.StartProfiling(title.start(), false));
titles[i] = title.start();
}
- CHECK(!collection.StartProfiling(
- "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false));
+ CHECK(!collection.StartProfiling("maximum", false));
for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i)
i::DeleteArray(titles[i]);
}
@@ -694,7 +636,8 @@
v8::HandleScope hs(env->GetIsolate());
v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler();
- CHECK_EQ(0, profiler->GetProfileCount());
+ i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler);
+ CHECK_EQ(0, iprofiler->GetProfilesCount());
v8::Handle<v8::Script> script_a = v8::Script::Compile(v8::String::NewFromUtf8(
env->GetIsolate(), "function a() { startProfiling(); }\n"));
script_a->Run();
@@ -704,8 +647,8 @@
"b();\n"
"stopProfiling();\n"));
script_b->Run();
- CHECK_EQ(1, profiler->GetProfileCount());
- const v8::CpuProfile* profile = profiler->GetCpuProfile(0);
+ CHECK_EQ(1, iprofiler->GetProfilesCount());
+ const v8::CpuProfile* profile = ProfilerExtension::last_profile;
const v8::CpuProfileNode* current = profile->GetTopDownRoot();
reinterpret_cast<ProfileNode*>(
const_cast<v8::CpuProfileNode*>(current))->Print(0);
@@ -796,7 +739,8 @@
v8::HandleScope hs(env->GetIsolate());
v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler();
- CHECK_EQ(0, profiler->GetProfileCount());
+ i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler);
+ CHECK_EQ(0, iprofiler->GetProfilesCount());
v8::Handle<v8::Script> script =
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
"function TryCatch() {\n"
@@ -812,8 +756,9 @@
"TryFinally();\n"
"stopProfiling();"));
script->Run();
- CHECK_EQ(1, profiler->GetProfileCount());
- const v8::CpuProfile* profile = profiler->GetCpuProfile(0);
+ CHECK_EQ(1, iprofiler->GetProfilesCount());
+ const v8::CpuProfile* profile = ProfilerExtension::last_profile;
+ CHECK(profile);
const v8::CpuProfileNode* current = profile->GetTopDownRoot();
reinterpret_cast<ProfileNode*>(
const_cast<v8::CpuProfileNode*>(current))->Print(0);
diff --git a/test/cctest/test-thread-termination.cc b/test/cctest/test-thread-termination.cc
index 94c739f..8e26032 100644
--- a/test/cctest/test-thread-termination.cc
+++ b/test/cctest/test-thread-termination.cc
@@ -107,13 +107,13 @@
v8::FunctionCallback doloop) {
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
global->Set(v8::String::NewFromUtf8(isolate, "terminate"),
- v8::FunctionTemplate::New(terminate));
+ v8::FunctionTemplate::New(isolate, terminate));
global->Set(v8::String::NewFromUtf8(isolate, "fail"),
- v8::FunctionTemplate::New(Fail));
+ v8::FunctionTemplate::New(isolate, Fail));
global->Set(v8::String::NewFromUtf8(isolate, "loop"),
- v8::FunctionTemplate::New(Loop));
+ v8::FunctionTemplate::New(isolate, Loop));
global->Set(v8::String::NewFromUtf8(isolate, "doloop"),
- v8::FunctionTemplate::New(doloop));
+ v8::FunctionTemplate::New(isolate, doloop));
return global;
}
@@ -242,27 +242,28 @@
// Test that we correctly handle termination exceptions if they are
// triggered by the creation of error objects in connection with ICs.
TEST(TerminateLoadICException) {
- v8::HandleScope scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
global->Set(
- v8::String::NewFromUtf8(CcTest::isolate(), "terminate_or_return_object"),
- v8::FunctionTemplate::New(TerminateOrReturnObject));
- global->Set(v8::String::NewFromUtf8(CcTest::isolate(), "fail"),
- v8::FunctionTemplate::New(Fail));
- global->Set(v8::String::NewFromUtf8(CcTest::isolate(), "loop"),
- v8::FunctionTemplate::New(LoopGetProperty));
+ v8::String::NewFromUtf8(isolate, "terminate_or_return_object"),
+ v8::FunctionTemplate::New(isolate, TerminateOrReturnObject));
+ global->Set(v8::String::NewFromUtf8(isolate, "fail"),
+ v8::FunctionTemplate::New(isolate, Fail));
+ global->Set(v8::String::NewFromUtf8(isolate, "loop"),
+ v8::FunctionTemplate::New(isolate, LoopGetProperty));
v8::Handle<v8::Context> context =
- v8::Context::New(CcTest::isolate(), NULL, global);
+ v8::Context::New(isolate, NULL, global);
v8::Context::Scope context_scope(context);
- CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
+ CHECK(!v8::V8::IsExecutionTerminating(isolate));
// Run a loop that will be infinite if thread termination does not work.
v8::Handle<v8::String> source = v8::String::NewFromUtf8(
- CcTest::isolate(), "try { loop(); fail(); } catch(e) { fail(); }");
+ isolate, "try { loop(); fail(); } catch(e) { fail(); }");
call_count = 0;
v8::Script::Compile(source)->Run();
// Test that we can run the code again after thread termination.
- CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
+ CHECK(!v8::V8::IsExecutionTerminating(isolate));
call_count = 0;
v8::Script::Compile(source)->Run();
}
@@ -299,20 +300,21 @@
// Test that reentry into V8 while the termination exception is still pending
// (has not yet unwound the 0-level JS frame) does not crash.
TEST(TerminateAndReenterFromThreadItself) {
- v8::HandleScope scope(CcTest::isolate());
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate(
- CcTest::isolate(), TerminateCurrentThread, ReenterAfterTermination);
+ isolate, TerminateCurrentThread, ReenterAfterTermination);
v8::Handle<v8::Context> context =
- v8::Context::New(CcTest::isolate(), NULL, global);
+ v8::Context::New(isolate, NULL, global);
v8::Context::Scope context_scope(context);
CHECK(!v8::V8::IsExecutionTerminating());
v8::Handle<v8::String> source = v8::String::NewFromUtf8(
- CcTest::isolate(), "try { loop(); fail(); } catch(e) { fail(); }");
+ isolate, "try { loop(); fail(); } catch(e) { fail(); }");
v8::Script::Compile(source)->Run();
- CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
+ CHECK(!v8::V8::IsExecutionTerminating(isolate));
// Check we can run JS again after termination.
CHECK(v8::Script::Compile(
- v8::String::NewFromUtf8(CcTest::isolate(),
+ v8::String::NewFromUtf8(isolate,
"function f() { return true; }"
"f()"))
->Run()
diff --git a/test/cctest/test-weakmaps.cc b/test/cctest/test-weakmaps.cc
index 8cb0aab..97eca86 100644
--- a/test/cctest/test-weakmaps.cc
+++ b/test/cctest/test-weakmaps.cc
@@ -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 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 @@
// 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()));
diff --git a/test/cctest/test-weaksets.cc b/test/cctest/test-weaksets.cc
index ee75744..514b6b2 100644
--- a/test/cctest/test-weaksets.cc
+++ b/test/cctest/test-weaksets.cc
@@ -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 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 @@
// 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()));
diff --git a/test/mjsunit/switch-opt.js b/test/mjsunit/switch-opt.js
new file mode 100644
index 0000000..c1d5d38
--- /dev/null
+++ b/test/mjsunit/switch-opt.js
@@ -0,0 +1,221 @@
+// Copyright 2013 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Flags: --allow-natives-syntax
+
+(function() {
+ var result = [];
+ var x = 0;
+
+ function branch(b) {
+ if (b == "deopt") {
+ %DeoptimizeFunction(f);
+ return "c";
+ }
+
+ return b ? "a" : "b";
+ }
+
+ function f(label, b1, b2, b3) {
+ switch (label) {
+ case "string":
+ result.push(1);
+ break;
+ case branch(b1) + branch(b2):
+ result.push(2);
+ break;
+ case 10:
+ result.push(3);
+ break;
+ default:
+ branch(b3);
+ result.push(4);
+ break;
+ case x++:
+ branch(b3);
+ result.push(5);
+ break;
+ }
+ }
+
+ function assertResult(r, label, b1, b2, b3) {
+ f(label, b1, b2, b3);
+ assertEquals(result, r);
+ result = [];
+ }
+
+ // Warmup.
+ assertResult([2], "aa", true, true);
+ assertResult([2], "ab", true, false);
+ assertResult([2], "ba", false, true);
+ assertResult([2], "bb", false, false);
+ assertEquals(0, x);
+ assertResult([4], "other");
+ assertEquals(1, x);
+ assertResult([5], 1, true, true);
+ assertResult([4], 1, true, true);
+ assertResult([5], 3, true, true);
+ assertResult([4], 3, true, true);
+ assertResult([5], 5, true, true);
+ assertResult([4], 5, true, true);
+ assertEquals(7, x);
+
+ // Test regular behavior.
+ %OptimizeFunctionOnNextCall(f);
+ assertResult([2], "aa", true, true);
+ assertResult([1], "string");
+ assertResult([4], "other");
+ assertEquals(8, x);
+ assertResult([5], 8);
+ assertEquals(9, x);
+
+ // Test deopt at the beginning of the case label evaluation.
+ assertResult([2], "ca", "deopt", true);
+ %OptimizeFunctionOnNextCall(f);
+ assertResult([4], "ca", "deopt", false);
+ assertEquals(10, x);
+ %OptimizeFunctionOnNextCall(f);
+
+ // Test deopt in the middle of the case label evaluation.
+ assertResult([2], "ac", true, "deopt");
+ %OptimizeFunctionOnNextCall(f);
+ assertResult([4], "ac", false, "deopt");
+ assertEquals(11, x);
+
+ // Test deopt in the default case.
+ %OptimizeFunctionOnNextCall(f);
+ print("here");
+ assertResult([4], 10000, false, false, "deopt");
+ assertEquals(12, x);
+
+ // Test deopt in the default case.
+ %OptimizeFunctionOnNextCall(f);
+ assertResult([4], 10000, false, false, "deopt");
+ assertEquals(13, x);
+
+ // Test deopt in x++ case.
+ %OptimizeFunctionOnNextCall(f);
+ assertResult([5], 13, false, false, "deopt");
+ assertEquals(14, x);
+})();
+
+
+(function() {
+ var result = [];
+ var x = 0;
+
+ function branch(b) {
+ if (b == "deopt") {
+ %DeoptimizeFunction(f);
+ return "c";
+ }
+
+ return b ? "a" : "b";
+ }
+
+ function f(label, b1, b2, b3) {
+ switch (label) {
+ case "string":
+ result.push(1);
+ break;
+ case branch(b1) + branch(b2):
+ result.push(2);
+ // Fall through.
+ case 10:
+ result.push(3);
+ break;
+ default:
+ branch(b3);
+ result.push(4);
+ // Fall through.
+ case x++:
+ branch(b3);
+ result.push(5);
+ break;
+ }
+ }
+
+ function assertResult(r, label, b1, b2, b3) {
+ f(label, b1, b2, b3);
+ assertEquals(r, result);
+ result = [];
+ }
+
+ // Warmup.
+ assertResult([2,3], "aa", true, true);
+ assertResult([2,3], "ab", true, false);
+ assertResult([2,3], "ba", false, true);
+ assertResult([2,3], "bb", false, false);
+ assertEquals(0, x);
+ assertResult([4,5], "other");
+ assertEquals(1, x);
+ assertResult([5], 1, true, true);
+ assertResult([4,5], 1, true, true);
+ assertResult([5], 3, true, true);
+ assertResult([4,5], 3, true, true);
+ assertResult([5], 5, true, true);
+ assertResult([4,5], 5, true, true);
+ assertEquals(7, x);
+
+ // Test regular behavior.
+ %OptimizeFunctionOnNextCall(f);
+ assertResult([2,3], "aa", true, true);
+ assertResult([1], "string");
+ assertResult([4,5], "other");
+ assertEquals(8, x);
+ assertResult([5], 8);
+ assertEquals(9, x);
+
+ // Test deopt at the beginning of the case label evaluation.
+ assertResult([2,3], "ca", "deopt", true);
+ %OptimizeFunctionOnNextCall(f);
+ assertResult([4,5], "ca", "deopt", false);
+ assertEquals(10, x);
+ %OptimizeFunctionOnNextCall(f);
+
+ // Test deopt in the middle of the case label evaluation.
+ assertResult([2,3], "ac", true, "deopt");
+ %OptimizeFunctionOnNextCall(f);
+ assertResult([4,5], "ac", false, "deopt");
+ assertEquals(11, x);
+
+ // Test deopt in the default case.
+ %OptimizeFunctionOnNextCall(f);
+ print("here");
+ assertResult([4,5], 10000, false, false, "deopt");
+ assertEquals(12, x);
+
+ // Test deopt in the default case.
+ %OptimizeFunctionOnNextCall(f);
+ assertResult([4,5], 10000, false, false, "deopt");
+ assertEquals(13, x);
+
+ // Test deopt in x++ case.
+ %OptimizeFunctionOnNextCall(f);
+ assertResult([5], 13, false, false, "deopt");
+ assertEquals(14, x);
+})();