Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge commit '29157ad7bff859837056a5755109c5ac65fbe012' into hj-dev-p…

…alfia
  • Loading branch information...
commit bada9f94c2e7c496775d1a54e1527862363b1b6c 2 parents 15c2f59 + 29157ad
Akos Palfi authored
Showing with 2,135 additions and 1,063 deletions.
  1. +107 −28 include/v8-profiler.h
  2. +14 −0 include/v8.h
  3. +185 −33 src/api.cc
  4. +26 −54 src/arm/code-stubs-arm.cc
  5. +1 −4 src/ast.cc
  6. +0 −3  src/ast.h
  7. +15 −0 src/bootstrapper.cc
  8. +16 −2 src/code-stubs-hydrogen.cc
  9. +2 −4 src/code-stubs.cc
  10. +8 −19 src/code-stubs.h
  11. +2 −1  src/codegen.cc
  12. +1 −1  src/compiler.cc
  13. +44 −105 src/cpu-profiler.cc
  14. +45 −58 src/cpu-profiler.h
  15. +78 −25 src/deoptimizer.cc
  16. +10 −2 src/deoptimizer.h
  17. +7 −2 src/elements-kind.h
  18. +3 −0  src/flag-definitions.h
  19. +12 −11 src/frames.cc
  20. +18 −107 src/heap-profiler.cc
  21. +13 −33 src/heap-profiler.h
  22. +4 −8 src/heap-snapshot-generator.cc
  23. +1 −9 src/heap-snapshot-generator.h
  24. +8 −5 src/heap.cc
  25. +2 −3 src/heap.h
  26. +18 −1 src/hydrogen-instructions.cc
  27. +8 −0 src/hydrogen-instructions.h
  28. +52 −12 src/hydrogen.cc
  29. +8 −0 src/hydrogen.h
  30. +5 −22 src/ia32/code-stubs-ia32.cc
  31. +34 −32 src/ic.cc
  32. +1 −0  src/ic.h
  33. +26 −6 src/isolate.cc
  34. +5 −5 src/isolate.h
  35. +19 −29 src/json-parser.h
  36. +4 −12 src/json-stringifier.h
  37. +8 −8 src/log.cc
  38. +1 −0  src/log.h
  39. +2 −0  src/macros.py
  40. +54 −49 src/messages.js
  41. +19 −50 src/mips/code-stubs-mips.cc
  42. +11 −0 src/objects-debug.cc
  43. +19 −0 src/objects-inl.h
  44. +12 −0 src/objects-printer.cc
  45. +1 −0  src/objects-visiting.cc
  46. +35 −22 src/objects.cc
  47. +30 −2 src/objects.h
  48. +3 −2 src/platform-cygwin.cc
  49. +1 −1  src/platform-freebsd.cc
  50. +1 −1  src/platform-linux.cc
  51. +3 −2 src/platform-macos.cc
  52. +1 −1  src/platform-openbsd.cc
  53. +1 −1  src/platform-solaris.cc
  54. +3 −2 src/platform-win32.cc
  55. +2 −1  src/profile-generator-inl.h
  56. +9 −10 src/profile-generator.cc
  57. +14 −5 src/profile-generator.h
  58. +171 −23 src/runtime.cc
  59. +6 −0 src/runtime.h
  60. +0 −17 src/spaces-inl.h
  61. +0 −5 src/spaces.h
  62. +98 −0 src/typedarray.js
  63. +5 −31 src/x64/code-stubs-x64.cc
  64. +83 −84 test/cctest/test-cpu-profiler.cc
  65. +134 −96 test/cctest/test-heap-profiler.cc
  66. +100 −13 test/cctest/test-profile-generator.cc
  67. +19 −0 test/mjsunit/harmony/symbols.js
  68. +136 −0 test/mjsunit/harmony/typedarrays.js
  69. +44 −0 test/mjsunit/regress/regress-105.js
  70. +122 −0 test/mjsunit/regress/regress-2564.js
  71. +56 −0 test/mjsunit/regress/regress-2596.js
  72. +87 −0 test/mjsunit/regress/regress-crbug-171715.js
  73. +40 −0 test/mjsunit/regress/regress-crbug-217858.js
  74. +2 −1  tools/gyp/v8.gyp
View
135 include/v8-profiler.h
@@ -105,6 +105,9 @@ class V8EXPORT CpuProfileNode {
/** Returns function entry UID. */
unsigned GetCallUid() const;
+ /** Returns id of the node. The id is unique within the tree */
+ unsigned GetNodeId() const;
+
/** Returns child nodes count of the node. */
int GetChildrenCount() const;
@@ -131,6 +134,18 @@ class V8EXPORT CpuProfile {
const CpuProfileNode* GetTopDownRoot() const;
/**
+ * Returns number of samples recorded. The samples are not recorded unless
+ * |record_samples| parameter of CpuProfiler::StartCpuProfiling is true.
+ */
+ int GetSamplesCount() const;
+
+ /**
+ * Returns profile node corresponding to the top frame the sample at
+ * the given index.
+ */
+ const CpuProfileNode* GetSample(int index) const;
+
+ /**
* Deletes the profile and removes it from CpuProfiler's list.
* All pointers to nodes previously returned become invalid.
* Profiles with the same uid but obtained using different
@@ -143,7 +158,8 @@ class V8EXPORT CpuProfile {
/**
- * Interface for controlling CPU profiling.
+ * Interface for controlling CPU profiling. Instance of the
+ * profiler can be retrieved using v8::Isolate::GetCpuProfiler.
*/
class V8EXPORT CpuProfiler {
public:
@@ -156,22 +172,34 @@ class V8EXPORT CpuProfiler {
* obtaining profiling results.
*/
+ /** Deprecated. Use GetProfileCount instead. */
+ static int GetProfilesCount();
/**
* Returns the number of profiles collected (doesn't include
* profiles that are being collected at the moment of call.)
*/
- static int GetProfilesCount();
+ int GetProfileCount();
- /** Returns a profile by index. */
+ /** Deprecated. Use GetCpuProfile instead. */
static const CpuProfile* GetProfile(
int index,
Handle<Value> security_token = Handle<Value>());
+ /** Returns a profile by index. */
+ const CpuProfile* GetCpuProfile(
+ int index,
+ Handle<Value> security_token = Handle<Value>());
- /** Returns a profile by uid. */
+ /** Deprecated. Use FindProfile instead. */
static const CpuProfile* FindProfile(
unsigned uid,
Handle<Value> security_token = Handle<Value>());
+ /** Returns a profile by uid. */
+ const CpuProfile* FindCpuProfile(
+ unsigned uid,
+ Handle<Value> security_token = Handle<Value>());
+ /** Deprecated. Use StartCpuProfiling instead. */
+ static void StartProfiling(Handle<String> title, bool record_samples = false);
/**
* Starts collecting CPU profile. Title may be an empty string. It
* is allowed to have several profiles being collected at
@@ -179,23 +207,38 @@ class V8EXPORT CpuProfiler {
* title are silently ignored. While collecting a profile, functions
* from all security contexts are included in it. The token-based
* filtering is only performed when querying for a profile.
+ *
+ * |record_samples| parameter controls whether individual samples should
+ * be recorded in addition to the aggregated tree.
*/
- static void StartProfiling(Handle<String> title);
+ void StartCpuProfiling(Handle<String> title, bool record_samples = false);
+ /** Deprecated. Use StopCpuProfiling instead. */
+ static const CpuProfile* StopProfiling(
+ Handle<String> title,
+ Handle<Value> security_token = Handle<Value>());
/**
* Stops collecting CPU profile with a given title and returns it.
* If the title given is empty, finishes the last profile started.
*/
- static const CpuProfile* StopProfiling(
+ const CpuProfile* StopCpuProfiling(
Handle<String> title,
Handle<Value> security_token = Handle<Value>());
+ /** Deprecated. Use DeleteAllCpuProfiles instead. */
+ static void DeleteAllProfiles();
/**
* Deletes all existing profiles, also cancelling all profiling
* activity. All previously returned pointers to profiles and their
* contents become invalid after this call.
*/
- static void DeleteAllProfiles();
+ void DeleteAllCpuProfiles();
+
+ private:
+ CpuProfiler();
+ ~CpuProfiler();
+ CpuProfiler(const CpuProfiler&);
+ CpuProfiler& operator=(const CpuProfiler&);
};
@@ -303,8 +346,8 @@ class V8EXPORT HeapSnapshot {
kJSON = 0 // See format description near 'Serialize' method.
};
- /** Returns heap snapshot type. */
- Type GetType() const;
+ /** Deprecated. Returns kFull. */
+ V8_DEPRECATED(Type GetType() const);
/** Returns heap snapshot UID (assigned by the profiler.) */
unsigned GetUid() const;
@@ -367,7 +410,8 @@ class V8EXPORT HeapSnapshot {
class RetainedObjectInfo;
/**
- * Interface for controlling heap profiling.
+ * Interface for controlling heap profiling. Instance of the
+ * profiler can be retrieved using v8::Isolate::GetHeapProfiler.
*/
class V8EXPORT HeapProfiler {
public:
@@ -380,20 +424,28 @@ class V8EXPORT HeapProfiler {
typedef RetainedObjectInfo* (*WrapperInfoCallback)
(uint16_t class_id, Handle<Value> wrapper);
- /** Returns the number of snapshots taken. */
+ /** Deprecated. Use GetSnapshotCount instead. */
static int GetSnapshotsCount();
+ /** Returns the number of snapshots taken. */
+ int GetSnapshotCount();
- /** Returns a snapshot by index. */
+ /** Deprecated. Use GetHeapSnapshot instead. */
static const HeapSnapshot* GetSnapshot(int index);
+ /** Returns a snapshot by index. */
+ const HeapSnapshot* GetHeapSnapshot(int index);
- /** Returns a profile by uid. */
+ /** Deprecated. Use FindHeapSnapshot instead. */
static const HeapSnapshot* FindSnapshot(unsigned uid);
+ /** Returns a profile by uid. */
+ const HeapSnapshot* FindHeapSnapshot(unsigned uid);
+ /** Deprecated. Use GetObjectId instead. */
+ static SnapshotObjectId GetSnapshotObjectId(Handle<Value> value);
/**
* Returns SnapshotObjectId for a heap object referenced by |value| if
* it has been seen by the heap profiler, kUnknownObjectId otherwise.
*/
- static SnapshotObjectId GetSnapshotObjectId(Handle<Value> value);
+ SnapshotObjectId GetObjectId(Handle<Value> value);
/**
* A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return
@@ -406,33 +458,42 @@ class V8EXPORT HeapProfiler {
* Callback interface for retrieving user friendly names of global objects.
*/
class ObjectNameResolver {
- public:
+ public:
/**
* Returns name to be used in the heap snapshot for given node. Returned
* string must stay alive until snapshot collection is completed.
*/
virtual const char* GetName(Handle<Object> object) = 0;
- protected:
+ protected:
virtual ~ObjectNameResolver() {}
};
+ /** Deprecated. Use TakeHeapSnapshot instead. */
+ static const HeapSnapshot* TakeSnapshot(
+ Handle<String> title,
+ HeapSnapshot::Type type = HeapSnapshot::kFull,
+ ActivityControl* control = NULL,
+ ObjectNameResolver* global_object_name_resolver = NULL);
/**
* Takes a heap snapshot and returns it. Title may be an empty string.
- * See HeapSnapshot::Type for types description.
*/
- static const HeapSnapshot* TakeSnapshot(
+ const HeapSnapshot* TakeHeapSnapshot(
Handle<String> title,
- HeapSnapshot::Type type = HeapSnapshot::kFull,
ActivityControl* control = NULL,
ObjectNameResolver* global_object_name_resolver = NULL);
+
+ /** Deprecated. Use StartTrackingHeapObjects instead. */
+ static void StartHeapObjectsTracking();
/**
* Starts tracking of heap objects population statistics. After calling
* this method, all heap objects relocations done by the garbage collector
* are being registered.
*/
- static void StartHeapObjectsTracking();
+ void StartTrackingHeapObjects();
+ /** Deprecated. Use GetHeapStats instead. */
+ static SnapshotObjectId PushHeapObjectsStats(OutputStream* stream);
/**
* Adds a new time interval entry to the aggregated statistics array. The
* time interval entry contains information on the current heap objects
@@ -442,28 +503,36 @@ class V8EXPORT HeapProfiler {
* HeapStatsUpdate structure instances.
* The return value of the function is the last seen heap object Id.
*
- * StartHeapObjectsTracking must be called before the first call to this
+ * StartTrackingHeapObjects must be called before the first call to this
* method.
*/
- static SnapshotObjectId PushHeapObjectsStats(OutputStream* stream);
+ SnapshotObjectId GetHeapStats(OutputStream* stream);
+ /** Deprecated. Use StopTrackingHeapObjects instead. */
+ static void StopHeapObjectsTracking();
/**
* Stops tracking of heap objects population statistics, cleans up all
* collected data. StartHeapObjectsTracking must be called again prior to
* calling PushHeapObjectsStats next time.
*/
- static void StopHeapObjectsTracking();
+ void StopTrackingHeapObjects();
+ /** Deprecated. Use DeleteAllHeapSnapshots instead. */
+ static void DeleteAllSnapshots();
/**
* Deletes all snapshots taken. All previously returned pointers to
* snapshots and their contents become invalid after this call.
*/
- static void DeleteAllSnapshots();
+ void DeleteAllHeapSnapshots();
- /** Binds a callback to embedder's class ID. */
+ /** Deprecated. Use SetWrapperClassInfoProvider instead. */
static void DefineWrapperClass(
uint16_t class_id,
WrapperInfoCallback callback);
+ /** Binds a callback to embedder's class ID. */
+ void SetWrapperClassInfoProvider(
+ uint16_t class_id,
+ WrapperInfoCallback callback);
/**
* Default value of persistent handle class ID. Must not be used to
@@ -472,11 +541,21 @@ class V8EXPORT HeapProfiler {
*/
static const uint16_t kPersistentHandleNoClassId = 0;
- /** Returns the number of currently existing persistent handles. */
+ /**
+ * Deprecated. Returns the number of currently existing persistent handles.
+ */
static int GetPersistentHandleCount();
- /** Returns memory used for profiler internal data and snapshots. */
+ /** Deprecated. Use GetHeapProfilerMemorySize instead. */
static size_t GetMemorySizeUsedByProfiler();
+ /** Returns memory used for profiler internal data and snapshots. */
+ size_t GetProfilerMemorySize();
+
+ private:
+ HeapProfiler();
+ ~HeapProfiler();
+ HeapProfiler(const HeapProfiler&);
+ HeapProfiler& operator=(const HeapProfiler&);
};
@@ -556,7 +635,7 @@ class V8EXPORT RetainedObjectInfo { // NOLINT
/**
* A struct for exporting HeapStats data from V8, using "push" model.
- * See HeapProfiler::PushHeapObjectsStats.
+ * See HeapProfiler::GetHeapStats.
*/
struct HeapStatsUpdate {
HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size)
View
14 include/v8.h
@@ -103,12 +103,14 @@ class Array;
class Boolean;
class BooleanObject;
class Context;
+class CpuProfiler;
class Data;
class Date;
class DeclaredAccessorDescriptor;
class External;
class Function;
class FunctionTemplate;
+class HeapProfiler;
class ImplementationUtilities;
class Int32;
class Integer;
@@ -3022,6 +3024,18 @@ class V8EXPORT Isolate {
*/
intptr_t AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes);
+ /**
+ * Returns heap profiler for this isolate. Will return NULL until the isolate
+ * is initialized.
+ */
+ HeapProfiler* GetHeapProfiler();
+
+ /**
+ * Returns CPU profiler for this isolate. Will return NULL until the isolate
+ * is initialized.
+ */
+ CpuProfiler* GetCpuProfiler();
+
private:
Isolate();
Isolate(const Isolate&);
View
218 src/api.cc
@@ -5799,6 +5799,20 @@ intptr_t V8::AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes) {
}
+HeapProfiler* Isolate::GetHeapProfiler() {
+ i::HeapProfiler* heap_profiler =
+ reinterpret_cast<i::Isolate*>(this)->heap_profiler();
+ return reinterpret_cast<HeapProfiler*>(heap_profiler);
+}
+
+
+CpuProfiler* Isolate::GetCpuProfiler() {
+ i::CpuProfiler* cpu_profiler =
+ reinterpret_cast<i::Isolate*>(this)->cpu_profiler();
+ return reinterpret_cast<CpuProfiler*>(cpu_profiler);
+}
+
+
void V8::SetGlobalGCPrologueCallback(GCCallback callback) {
i::Isolate* isolate = i::Isolate::Current();
if (IsDeadCheck(isolate, "v8::V8::SetGlobalGCPrologueCallback()")) return;
@@ -5971,6 +5985,14 @@ void Isolate::Exit() {
void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
+ if (!isolate->IsInitialized()) {
+ heap_statistics->total_heap_size_ = 0;
+ heap_statistics->total_heap_size_executable_ = 0;
+ heap_statistics->total_physical_size_ = 0;
+ heap_statistics->used_heap_size_ = 0;
+ heap_statistics->heap_size_limit_ = 0;
+ return;
+ }
i::Heap* heap = isolate->heap();
heap_statistics->total_heap_size_ = heap->CommittedMemory();
heap_statistics->total_heap_size_executable_ =
@@ -6446,6 +6468,11 @@ unsigned CpuProfileNode::GetCallUid() const {
}
+unsigned CpuProfileNode::GetNodeId() const {
+ return reinterpret_cast<const i::ProfileNode*>(this)->id();
+}
+
+
int CpuProfileNode::GetChildrenCount() const {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::CpuProfileNode::GetChildrenCount");
@@ -6465,11 +6492,12 @@ const CpuProfileNode* CpuProfileNode::GetChild(int index) const {
void CpuProfile::Delete() {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::CpuProfile::Delete");
- i::CpuProfiler::DeleteProfile(reinterpret_cast<i::CpuProfile*>(this));
- if (i::CpuProfiler::GetProfilesCount() == 0 &&
- !i::CpuProfiler::HasDetachedProfiles()) {
+ i::CpuProfiler* profiler = isolate->cpu_profiler();
+ ASSERT(profiler != NULL);
+ profiler->DeleteProfile(reinterpret_cast<i::CpuProfile*>(this));
+ if (profiler->GetProfilesCount() == 0 && !profiler->HasDetachedProfiles()) {
// If this was the last profile, clean up all accessory data as well.
- i::CpuProfiler::DeleteAllProfiles();
+ profiler->DeleteAllProfiles();
}
}
@@ -6498,10 +6526,28 @@ const CpuProfileNode* CpuProfile::GetTopDownRoot() const {
}
+const CpuProfileNode* CpuProfile::GetSample(int index) const {
+ const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
+ return reinterpret_cast<const CpuProfileNode*>(profile->sample(index));
+}
+
+
+int CpuProfile::GetSamplesCount() const {
+ return reinterpret_cast<const i::CpuProfile*>(this)->samples_count();
+}
+
+
int CpuProfiler::GetProfilesCount() {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::CpuProfiler::GetProfilesCount");
- return i::CpuProfiler::GetProfilesCount();
+ i::CpuProfiler* profiler = isolate->cpu_profiler();
+ ASSERT(profiler != NULL);
+ return profiler->GetProfilesCount();
+}
+
+
+int CpuProfiler::GetProfileCount() {
+ return reinterpret_cast<i::CpuProfiler*>(this)->GetProfilesCount();
}
@@ -6509,8 +6555,19 @@ const CpuProfile* CpuProfiler::GetProfile(int index,
Handle<Value> security_token) {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::CpuProfiler::GetProfile");
+ i::CpuProfiler* profiler = isolate->cpu_profiler();
+ ASSERT(profiler != NULL);
+ return reinterpret_cast<const CpuProfile*>(
+ profiler->GetProfile(
+ security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
+ index));
+}
+
+
+const CpuProfile* CpuProfiler::GetCpuProfile(int index,
+ Handle<Value> security_token) {
return reinterpret_cast<const CpuProfile*>(
- i::CpuProfiler::GetProfile(
+ reinterpret_cast<i::CpuProfiler*>(this)->GetProfile(
security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
index));
}
@@ -6520,17 +6577,36 @@ const CpuProfile* CpuProfiler::FindProfile(unsigned uid,
Handle<Value> security_token) {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::CpuProfiler::FindProfile");
+ i::CpuProfiler* profiler = isolate->cpu_profiler();
+ ASSERT(profiler != NULL);
return reinterpret_cast<const CpuProfile*>(
- i::CpuProfiler::FindProfile(
+ profiler->FindProfile(
security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
uid));
}
-void CpuProfiler::StartProfiling(Handle<String> title) {
+const CpuProfile* CpuProfiler::FindCpuProfile(unsigned uid,
+ Handle<Value> security_token) {
+ return reinterpret_cast<const CpuProfile*>(
+ reinterpret_cast<i::CpuProfiler*>(this)->FindProfile(
+ security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
+ uid));
+}
+
+
+void CpuProfiler::StartProfiling(Handle<String> title, bool record_samples) {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::CpuProfiler::StartProfiling");
- i::CpuProfiler::StartProfiling(*Utils::OpenHandle(*title));
+ i::CpuProfiler* profiler = isolate->cpu_profiler();
+ ASSERT(profiler != NULL);
+ profiler->StartProfiling(*Utils::OpenHandle(*title), record_samples);
+}
+
+
+void CpuProfiler::StartCpuProfiling(Handle<String> title, bool record_samples) {
+ reinterpret_cast<i::CpuProfiler*>(this)->StartProfiling(
+ *Utils::OpenHandle(*title), record_samples);
}
@@ -6538,8 +6614,19 @@ const CpuProfile* CpuProfiler::StopProfiling(Handle<String> title,
Handle<Value> security_token) {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::CpuProfiler::StopProfiling");
+ i::CpuProfiler* profiler = isolate->cpu_profiler();
+ ASSERT(profiler != NULL);
return reinterpret_cast<const CpuProfile*>(
- i::CpuProfiler::StopProfiling(
+ profiler->StopProfiling(
+ security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
+ *Utils::OpenHandle(*title)));
+}
+
+
+const CpuProfile* CpuProfiler::StopCpuProfiling(Handle<String> title,
+ Handle<Value> security_token) {
+ return reinterpret_cast<const CpuProfile*>(
+ reinterpret_cast<i::CpuProfiler*>(this)->StopProfiling(
security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
*Utils::OpenHandle(*title)));
}
@@ -6548,7 +6635,14 @@ const CpuProfile* CpuProfiler::StopProfiling(Handle<String> title,
void CpuProfiler::DeleteAllProfiles() {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::CpuProfiler::DeleteAllProfiles");
- i::CpuProfiler::DeleteAllProfiles();
+ i::CpuProfiler* profiler = isolate->cpu_profiler();
+ ASSERT(profiler != NULL);
+ profiler->DeleteAllProfiles();
+}
+
+
+void CpuProfiler::DeleteAllCpuProfiles() {
+ reinterpret_cast<i::CpuProfiler*>(this)->DeleteAllProfiles();
}
@@ -6671,11 +6765,11 @@ static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) {
void HeapSnapshot::Delete() {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapSnapshot::Delete");
- if (i::HeapProfiler::GetSnapshotsCount() > 1) {
+ if (isolate->heap_profiler()->GetSnapshotsCount() > 1) {
ToInternal(this)->Delete();
} else {
// If this is the last snapshot, clean up all accessory data as well.
- i::HeapProfiler::DeleteAllSnapshots();
+ isolate->heap_profiler()->DeleteAllSnapshots();
}
}
@@ -6683,7 +6777,7 @@ void HeapSnapshot::Delete() {
HeapSnapshot::Type HeapSnapshot::GetType() const {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapSnapshot::GetType");
- return static_cast<HeapSnapshot::Type>(ToInternal(this)->type());
+ return kFull;
}
@@ -6760,7 +6854,12 @@ void HeapSnapshot::Serialize(OutputStream* stream,
int HeapProfiler::GetSnapshotsCount() {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshotsCount");
- return i::HeapProfiler::GetSnapshotsCount();
+ return isolate->heap_profiler()->GetSnapshotsCount();
+}
+
+
+int HeapProfiler::GetSnapshotCount() {
+ return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotsCount();
}
@@ -6768,7 +6867,13 @@ const HeapSnapshot* HeapProfiler::GetSnapshot(int index) {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshot");
return reinterpret_cast<const HeapSnapshot*>(
- i::HeapProfiler::GetSnapshot(index));
+ isolate->heap_profiler()->GetSnapshot(index));
+}
+
+
+const HeapSnapshot* HeapProfiler::GetHeapSnapshot(int index) {
+ return reinterpret_cast<const HeapSnapshot*>(
+ reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshot(index));
}
@@ -6776,7 +6881,13 @@ const HeapSnapshot* HeapProfiler::FindSnapshot(unsigned uid) {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapProfiler::FindSnapshot");
return reinterpret_cast<const HeapSnapshot*>(
- i::HeapProfiler::FindSnapshot(uid));
+ isolate->heap_profiler()->FindSnapshot(uid));
+}
+
+
+const HeapSnapshot* HeapProfiler::FindHeapSnapshot(unsigned uid) {
+ return reinterpret_cast<const HeapSnapshot*>(
+ reinterpret_cast<i::HeapProfiler*>(this)->FindSnapshot(uid));
}
@@ -6784,7 +6895,13 @@ SnapshotObjectId HeapProfiler::GetSnapshotObjectId(Handle<Value> value) {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshotObjectId");
i::Handle<i::Object> obj = Utils::OpenHandle(*value);
- return i::HeapProfiler::GetSnapshotObjectId(obj);
+ return isolate->heap_profiler()->GetSnapshotObjectId(obj);
+}
+
+
+SnapshotObjectId HeapProfiler::GetObjectId(Handle<Value> value) {
+ i::Handle<i::Object> obj = Utils::OpenHandle(*value);
+ return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotObjectId(obj);
}
@@ -6794,45 +6911,67 @@ const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle<String> title,
ObjectNameResolver* resolver) {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapProfiler::TakeSnapshot");
- i::HeapSnapshot::Type internal_type = i::HeapSnapshot::kFull;
- switch (type) {
- case HeapSnapshot::kFull:
- internal_type = i::HeapSnapshot::kFull;
- break;
- default:
- UNREACHABLE();
- }
return reinterpret_cast<const HeapSnapshot*>(
- i::HeapProfiler::TakeSnapshot(
- *Utils::OpenHandle(*title), internal_type, control, resolver));
+ isolate->heap_profiler()->TakeSnapshot(
+ *Utils::OpenHandle(*title), control, resolver));
+}
+
+
+const HeapSnapshot* HeapProfiler::TakeHeapSnapshot(
+ Handle<String> title,
+ ActivityControl* control,
+ ObjectNameResolver* resolver) {
+ return reinterpret_cast<const HeapSnapshot*>(
+ reinterpret_cast<i::HeapProfiler*>(this)->TakeSnapshot(
+ *Utils::OpenHandle(*title), control, resolver));
}
void HeapProfiler::StartHeapObjectsTracking() {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapProfiler::StartHeapObjectsTracking");
- i::HeapProfiler::StartHeapObjectsTracking();
+ isolate->heap_profiler()->StartHeapObjectsTracking();
+}
+
+
+void HeapProfiler::StartTrackingHeapObjects() {
+ reinterpret_cast<i::HeapProfiler*>(this)->StartHeapObjectsTracking();
}
void HeapProfiler::StopHeapObjectsTracking() {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapProfiler::StopHeapObjectsTracking");
- i::HeapProfiler::StopHeapObjectsTracking();
+ isolate->heap_profiler()->StopHeapObjectsTracking();
+}
+
+
+void HeapProfiler::StopTrackingHeapObjects() {
+ reinterpret_cast<i::HeapProfiler*>(this)->StopHeapObjectsTracking();
}
SnapshotObjectId HeapProfiler::PushHeapObjectsStats(OutputStream* stream) {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapProfiler::PushHeapObjectsStats");
- return i::HeapProfiler::PushHeapObjectsStats(stream);
+ return isolate->heap_profiler()->PushHeapObjectsStats(stream);
+}
+
+
+SnapshotObjectId HeapProfiler::GetHeapStats(OutputStream* stream) {
+ return reinterpret_cast<i::HeapProfiler*>(this)->PushHeapObjectsStats(stream);
}
void HeapProfiler::DeleteAllSnapshots() {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapProfiler::DeleteAllSnapshots");
- i::HeapProfiler::DeleteAllSnapshots();
+ isolate->heap_profiler()->DeleteAllSnapshots();
+}
+
+
+void HeapProfiler::DeleteAllHeapSnapshots() {
+ reinterpret_cast<i::HeapProfiler*>(this)->DeleteAllSnapshots();
}
@@ -6843,6 +6982,13 @@ void HeapProfiler::DefineWrapperClass(uint16_t class_id,
}
+void HeapProfiler::SetWrapperClassInfoProvider(uint16_t class_id,
+ WrapperInfoCallback callback) {
+ reinterpret_cast<i::HeapProfiler*>(this)->DefineWrapperClass(class_id,
+ callback);
+}
+
+
int HeapProfiler::GetPersistentHandleCount() {
i::Isolate* isolate = i::Isolate::Current();
return isolate->global_handles()->NumberOfGlobalHandles();
@@ -6850,7 +6996,13 @@ int HeapProfiler::GetPersistentHandleCount() {
size_t HeapProfiler::GetMemorySizeUsedByProfiler() {
- return i::HeapProfiler::GetMemorySizeUsedByProfiler();
+ return i::Isolate::Current()->heap_profiler()->GetMemorySizeUsedByProfiler();
+}
+
+
+size_t HeapProfiler::GetProfilerMemorySize() {
+ return reinterpret_cast<i::HeapProfiler*>(this)->
+ GetMemorySizeUsedByProfiler();
}
View
80 src/arm/code-stubs-arm.cc
@@ -95,7 +95,7 @@ static void InitializeArrayConstructorDescriptor(Isolate* isolate,
// stack param count needs (constructor pointer, and single argument)
descriptor->stack_parameter_count_ = &r0;
descriptor->register_params_ = registers;
- descriptor->extra_expression_stack_count_ = 1;
+ descriptor->function_mode_ = JS_FUNCTION_STUB_MODE;
descriptor->deoptimization_handler_ =
FUNCTION_ADDR(ArrayConstructor_StubFailure);
}
@@ -4488,35 +4488,6 @@ void InstanceofStub::Generate(MacroAssembler* masm) {
}
-void ArrayLengthStub::Generate(MacroAssembler* masm) {
- Label miss;
- Register receiver;
- if (kind() == Code::KEYED_LOAD_IC) {
- // ----------- S t a t e -------------
- // -- lr : return address
- // -- r0 : key
- // -- r1 : receiver
- // -----------------------------------
- __ cmp(r0, Operand(masm->isolate()->factory()->length_string()));
- __ b(ne, &miss);
- receiver = r1;
- } else {
- ASSERT(kind() == Code::LOAD_IC);
- // ----------- S t a t e -------------
- // -- r2 : name
- // -- lr : return address
- // -- r0 : receiver
- // -- sp[0] : receiver
- // -----------------------------------
- receiver = r0;
- }
-
- StubCompiler::GenerateLoadArrayLength(masm, receiver, r3, &miss);
- __ bind(&miss);
- StubCompiler::TailCallBuiltin(masm, StubCompiler::MissBuiltin(kind()));
-}
-
-
void FunctionPrototypeStub::Generate(MacroAssembler* masm) {
Label miss;
Register receiver;
@@ -7414,33 +7385,31 @@ void NameDictionaryLookupStub::GenerateNegativeLookup(MacroAssembler* masm,
__ cmp(entity_name, tmp);
__ b(eq, done);
- if (i != kInlinedProbes - 1) {
- // Load the hole ready for use below:
- __ LoadRoot(tmp, Heap::kTheHoleValueRootIndex);
+ // Load the hole ready for use below:
+ __ LoadRoot(tmp, Heap::kTheHoleValueRootIndex);
- // Stop if found the property.
- __ cmp(entity_name, Operand(Handle<Name>(name)));
- __ b(eq, miss);
+ // Stop if found the property.
+ __ cmp(entity_name, Operand(Handle<Name>(name)));
+ __ b(eq, miss);
- Label good;
- __ cmp(entity_name, tmp);
- __ b(eq, &good);
+ Label good;
+ __ cmp(entity_name, tmp);
+ __ b(eq, &good);
- // Check if the entry name is not a unique name.
- __ ldr(entity_name, FieldMemOperand(entity_name, HeapObject::kMapOffset));
- __ ldrb(entity_name,
- FieldMemOperand(entity_name, Map::kInstanceTypeOffset));
- __ tst(entity_name, Operand(kIsInternalizedMask));
- __ b(ne, &good);
- __ cmp(entity_name, Operand(SYMBOL_TYPE));
- __ b(ne, miss);
-
- __ bind(&good);
-
- // Restore the properties.
- __ ldr(properties,
- FieldMemOperand(receiver, JSObject::kPropertiesOffset));
- }
+ // Check if the entry name is not a unique name.
+ __ ldr(entity_name, FieldMemOperand(entity_name, HeapObject::kMapOffset));
+ __ ldrb(entity_name,
+ FieldMemOperand(entity_name, Map::kInstanceTypeOffset));
+ __ tst(entity_name, Operand(kIsInternalizedMask));
+ __ b(ne, &good);
+ __ cmp(entity_name, Operand(SYMBOL_TYPE));
+ __ b(ne, miss);
+
+ __ bind(&good);
+
+ // Restore the properties.
+ __ ldr(properties,
+ FieldMemOperand(receiver, JSObject::kPropertiesOffset));
}
const int spill_mask =
@@ -7993,6 +7962,9 @@ void StubFailureTrampolineStub::Generate(MacroAssembler* masm) {
int parameter_count_offset =
StubFailureTrampolineFrame::kCallerStackParameterCountFrameOffset;
__ ldr(r1, MemOperand(fp, parameter_count_offset));
+ if (function_mode_ == JS_FUNCTION_STUB_MODE) {
+ __ add(r1, r1, Operand(1));
+ }
masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE);
__ mov(r1, Operand(r1, LSL, kPointerSizeLog2));
__ add(sp, sp, r1);
View
5 src/ast.cc
@@ -414,12 +414,9 @@ void Property::RecordTypeFeedback(TypeFeedbackOracle* oracle,
is_monomorphic_ = oracle->LoadIsMonomorphicNormal(this);
receiver_types_.Clear();
if (key()->IsPropertyName()) {
- ArrayLengthStub array_stub(Code::LOAD_IC);
FunctionPrototypeStub proto_stub(Code::LOAD_IC);
StringLengthStub string_stub(Code::LOAD_IC, false);
- if (oracle->LoadIsStub(this, &array_stub)) {
- is_array_length_ = true;
- } else if (oracle->LoadIsStub(this, &string_stub)) {
+ if (oracle->LoadIsStub(this, &string_stub)) {
is_string_length_ = true;
} else if (oracle->LoadIsStub(this, &proto_stub)) {
is_function_prototype_ = true;
View
3  src/ast.h
@@ -1488,7 +1488,6 @@ class Property: public Expression {
virtual KeyedAccessStoreMode GetStoreMode() {
return STANDARD_STORE;
}
- bool IsArrayLength() { return is_array_length_; }
bool IsUninitialized() { return is_uninitialized_; }
TypeFeedbackId PropertyFeedbackId() { return reuse(id()); }
@@ -1504,7 +1503,6 @@ class Property: public Expression {
load_id_(GetNextId(isolate)),
is_monomorphic_(false),
is_uninitialized_(false),
- is_array_length_(false),
is_string_length_(false),
is_string_access_(false),
is_function_prototype_(false) { }
@@ -1518,7 +1516,6 @@ class Property: public Expression {
SmallMapList receiver_types_;
bool is_monomorphic_ : 1;
bool is_uninitialized_ : 1;
- bool is_array_length_ : 1;
bool is_string_length_ : 1;
bool is_string_access_ : 1;
bool is_function_prototype_ : 1;
View
15 src/bootstrapper.cc
@@ -1311,6 +1311,16 @@ void Genesis::InitializeExperimentalGlobal() {
prototype, Builtins::kIllegal, true);
}
}
+
+ if (FLAG_harmony_typed_arrays) {
+ { // -- A r r a y B u f f e r
+ Handle<JSObject> prototype =
+ factory()->NewJSObject(isolate()->object_function(), TENURED);
+ InstallFunction(global, "__ArrayBuffer", JS_ARRAY_BUFFER_TYPE,
+ JSArrayBuffer::kSize, prototype,
+ Builtins::kIllegal, true);
+ }
+ }
}
@@ -1918,6 +1928,11 @@ bool Genesis::InstallExperimentalNatives() {
"native object-observe.js") == 0) {
if (!CompileExperimentalBuiltin(isolate(), i)) return false;
}
+ if (FLAG_harmony_typed_arrays &&
+ strcmp(ExperimentalNatives::GetScriptName(i).start(),
+ "native typedarray.js") == 0) {
+ if (!CompileExperimentalBuiltin(isolate(), i)) return false;
+ }
}
InstallExperimentalNativeFunctions();
View
18 src/code-stubs-hydrogen.cc
@@ -129,7 +129,8 @@ bool CodeStubGraphBuilderBase::BuildGraph() {
if (descriptor_->stack_parameter_count_ != NULL) {
ASSERT(descriptor_->environment_length() == (param_count + 1));
stack_parameter_count = new(zone) HParameter(param_count,
- HParameter::REGISTER_PARAMETER);
+ HParameter::REGISTER_PARAMETER,
+ Representation::Integer32());
// it's essential to bind this value to the environment in case of deopt
start_environment->Bind(param_count, stack_parameter_count);
AddInstruction(stack_parameter_count);
@@ -147,13 +148,26 @@ bool CodeStubGraphBuilderBase::BuildGraph() {
AddSimulate(BailoutId::StubEntry());
HValue* return_value = BuildCodeStub();
+
+ // We might have extra expressions to pop from the stack in addition to the
+ // arguments above
+ HInstruction* stack_pop_count = stack_parameter_count;
+ if (descriptor_->function_mode_ == JS_FUNCTION_STUB_MODE) {
+ HInstruction* amount = graph()->GetConstant1();
+ stack_pop_count = AddInstruction(
+ HAdd::New(zone, context_, stack_parameter_count, amount));
+ stack_pop_count->ChangeRepresentation(Representation::Integer32());
+ stack_pop_count->ClearFlag(HValue::kCanOverflow);
+ }
+
HReturn* hreturn_instruction = new(zone) HReturn(return_value,
context_,
- stack_parameter_count);
+ stack_pop_count);
current_block()->Finish(hreturn_instruction);
return true;
}
+
template <class Stub>
class CodeStubGraphBuilder: public CodeStubGraphBuilderBase {
public:
View
6 src/code-stubs.cc
@@ -619,10 +619,8 @@ void ElementsTransitionAndStoreStub::Generate(MacroAssembler* masm) {
void StubFailureTrampolineStub::GenerateAheadOfTime(Isolate* isolate) {
- int i = 0;
- for (; i <= StubFailureTrampolineStub::kMaxExtraExpressionStackCount; ++i) {
- StubFailureTrampolineStub(i).GetCode(isolate);
- }
+ StubFailureTrampolineStub(NOT_JS_FUNCTION_STUB_MODE).GetCode(isolate);
+ StubFailureTrampolineStub(JS_FUNCTION_STUB_MODE).GetCode(isolate);
}
View
27 src/code-stubs.h
@@ -47,7 +47,6 @@ namespace internal {
V(Compare) \
V(CompareIC) \
V(MathPow) \
- V(ArrayLength) \
V(StringLength) \
V(FunctionPrototype) \
V(StoreArrayLength) \
@@ -259,15 +258,17 @@ class PlatformCodeStub : public CodeStub {
};
+enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE };
+
struct CodeStubInterfaceDescriptor {
CodeStubInterfaceDescriptor()
: register_param_count_(-1),
stack_parameter_count_(NULL),
- extra_expression_stack_count_(0),
+ function_mode_(NOT_JS_FUNCTION_STUB_MODE),
register_params_(NULL) { }
int register_param_count_;
const Register* stack_parameter_count_;
- int extra_expression_stack_count_;
+ StubFunctionMode function_mode_;
Register* register_params_;
Address deoptimization_handler_;
@@ -597,16 +598,6 @@ class ICStub: public PlatformCodeStub {
};
-class ArrayLengthStub: public ICStub {
- public:
- explicit ArrayLengthStub(Code::Kind kind) : ICStub(kind) { }
- virtual void Generate(MacroAssembler* masm);
-
- private:
- virtual CodeStub::Major MajorKey() { return ArrayLength; }
-};
-
-
class FunctionPrototypeStub: public ICStub {
public:
explicit FunctionPrototypeStub(Code::Kind kind) : ICStub(kind) { }
@@ -1612,10 +1603,8 @@ class StoreArrayLiteralElementStub : public PlatformCodeStub {
class StubFailureTrampolineStub : public PlatformCodeStub {
public:
- static const int kMaxExtraExpressionStackCount = 1;
-
- explicit StubFailureTrampolineStub(int extra_expression_stack_count)
- : extra_expression_stack_count_(extra_expression_stack_count) {}
+ explicit StubFailureTrampolineStub(StubFunctionMode function_mode)
+ : function_mode_(function_mode) {}
virtual bool IsPregenerated() { return true; }
@@ -1623,11 +1612,11 @@ class StubFailureTrampolineStub : public PlatformCodeStub {
private:
Major MajorKey() { return StubFailureTrampoline; }
- int MinorKey() { return extra_expression_stack_count_; }
+ int MinorKey() { return static_cast<int>(function_mode_); }
void Generate(MacroAssembler* masm);
- int extra_expression_stack_count_;
+ StubFunctionMode function_mode_;
DISALLOW_COPY_AND_ASSIGN(StubFailureTrampolineStub);
};
View
3  src/codegen.cc
@@ -171,7 +171,8 @@ void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) {
bool CodeGenerator::ShouldGenerateLog(Expression* type) {
ASSERT(type != NULL);
Isolate* isolate = Isolate::Current();
- if (!isolate->logger()->is_logging() && !CpuProfiler::is_profiling(isolate)) {
+ if (!isolate->logger()->is_logging() &&
+ !isolate->cpu_profiler()->is_profiling()) {
return false;
}
Handle<String> name = Handle<String>::cast(type->AsLiteral()->handle());
View
2  src/compiler.cc
@@ -1134,7 +1134,7 @@ void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag,
// script name and line number. Check explicitly whether logging is
// enabled as finding the line number is not free.
if (info->isolate()->logger()->is_logging_code_events() ||
- CpuProfiler::is_profiling(info->isolate())) {
+ info->isolate()->cpu_profiler()->is_profiling()) {
Handle<Script> script = info->script();
Handle<Code> code = info->code();
if (*code == info->isolate()->builtins()->builtin(Builtins::kLazyCompile))
View
149 src/cpu-profiler.cc
@@ -258,109 +258,66 @@ void ProfilerEventsProcessor::Run() {
}
-void CpuProfiler::StartProfiling(const char* title) {
- ASSERT(Isolate::Current()->cpu_profiler() != NULL);
- Isolate::Current()->cpu_profiler()->StartCollectingProfile(title);
-}
-
-
-void CpuProfiler::StartProfiling(String* title) {
- ASSERT(Isolate::Current()->cpu_profiler() != NULL);
- Isolate::Current()->cpu_profiler()->StartCollectingProfile(title);
-}
-
-
-CpuProfile* CpuProfiler::StopProfiling(const char* title) {
- Isolate* isolate = Isolate::Current();
- return is_profiling(isolate) ?
- isolate->cpu_profiler()->StopCollectingProfile(title) : NULL;
-}
-
-
-CpuProfile* CpuProfiler::StopProfiling(Object* security_token, String* title) {
- Isolate* isolate = Isolate::Current();
- return is_profiling(isolate) ?
- isolate->cpu_profiler()->StopCollectingProfile(
- security_token, title) : NULL;
-}
-
-
int CpuProfiler::GetProfilesCount() {
- ASSERT(Isolate::Current()->cpu_profiler() != NULL);
// The count of profiles doesn't depend on a security token.
- return Isolate::Current()->cpu_profiler()->profiles_->Profiles(
- TokenEnumerator::kNoSecurityToken)->length();
+ return profiles_->Profiles(TokenEnumerator::kNoSecurityToken)->length();
}
CpuProfile* CpuProfiler::GetProfile(Object* security_token, int index) {
- ASSERT(Isolate::Current()->cpu_profiler() != NULL);
- CpuProfiler* profiler = Isolate::Current()->cpu_profiler();
- const int token = profiler->token_enumerator_->GetTokenId(security_token);
- return profiler->profiles_->Profiles(token)->at(index);
+ const int token = token_enumerator_->GetTokenId(security_token);
+ return profiles_->Profiles(token)->at(index);
}
CpuProfile* CpuProfiler::FindProfile(Object* security_token, unsigned uid) {
- ASSERT(Isolate::Current()->cpu_profiler() != NULL);
- CpuProfiler* profiler = Isolate::Current()->cpu_profiler();
- const int token = profiler->token_enumerator_->GetTokenId(security_token);
- return profiler->profiles_->GetProfile(token, uid);
+ const int token = token_enumerator_->GetTokenId(security_token);
+ return profiles_->GetProfile(token, uid);
}
-TickSample* CpuProfiler::TickSampleEvent(Isolate* isolate) {
- if (CpuProfiler::is_profiling(isolate)) {
- return isolate->cpu_profiler()->processor_->TickSampleEvent();
- } else {
- return NULL;
- }
+TickSample* CpuProfiler::TickSampleEvent() {
+ if (is_profiling_) return processor_->TickSampleEvent();
+ return NULL;
}
void CpuProfiler::DeleteAllProfiles() {
- Isolate* isolate = Isolate::Current();
- ASSERT(isolate->cpu_profiler() != NULL);
- if (is_profiling(isolate)) {
- isolate->cpu_profiler()->StopProcessor();
- }
- isolate->cpu_profiler()->ResetProfiles();
+ if (is_profiling_) StopProcessor();
+ ResetProfiles();
}
void CpuProfiler::DeleteProfile(CpuProfile* profile) {
- ASSERT(Isolate::Current()->cpu_profiler() != NULL);
- Isolate::Current()->cpu_profiler()->profiles_->RemoveProfile(profile);
+ profiles_->RemoveProfile(profile);
delete profile;
}
bool CpuProfiler::HasDetachedProfiles() {
- ASSERT(Isolate::Current()->cpu_profiler() != NULL);
- return Isolate::Current()->cpu_profiler()->profiles_->HasDetachedProfiles();
+ return profiles_->HasDetachedProfiles();
}
void CpuProfiler::CallbackEvent(Name* name, Address entry_point) {
- Isolate::Current()->cpu_profiler()->processor_->CallbackCreateEvent(
+ processor_->CallbackCreateEvent(
Logger::CALLBACK_TAG, CodeEntry::kEmptyNamePrefix, name, entry_point);
}
void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code, const char* comment) {
- Isolate::Current()->cpu_profiler()->processor_->CodeCreateEvent(
+ processor_->CodeCreateEvent(
tag, comment, code->address(), code->ExecutableSize());
}
void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code, Name* name) {
- Isolate* isolate = Isolate::Current();
- isolate->cpu_profiler()->processor_->CodeCreateEvent(
+ processor_->CodeCreateEvent(
tag,
name,
- isolate->heap()->empty_string(),
+ isolate_->heap()->empty_string(),
v8::CpuProfileNode::kNoLineNumberInfo,
code->address(),
code->ExecutableSize(),
@@ -372,11 +329,10 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code,
SharedFunctionInfo* shared,
Name* name) {
- Isolate* isolate = Isolate::Current();
- isolate->cpu_profiler()->processor_->CodeCreateEvent(
+ processor_->CodeCreateEvent(
tag,
name,
- isolate->heap()->empty_string(),
+ isolate_->heap()->empty_string(),
v8::CpuProfileNode::kNoLineNumberInfo,
code->address(),
code->ExecutableSize(),
@@ -388,7 +344,7 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code,
SharedFunctionInfo* shared,
String* source, int line) {
- Isolate::Current()->cpu_profiler()->processor_->CodeCreateEvent(
+ processor_->CodeCreateEvent(
tag,
shared->DebugName(),
source,
@@ -401,7 +357,7 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code, int args_count) {
- Isolate::Current()->cpu_profiler()->processor_->CodeCreateEvent(
+ processor_->CodeCreateEvent(
tag,
args_count,
code->address(),
@@ -410,7 +366,7 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
void CpuProfiler::CodeMoveEvent(Address from, Address to) {
- Isolate::Current()->cpu_profiler()->processor_->CodeMoveEvent(from, to);
+ processor_->CodeMoveEvent(from, to);
}
@@ -419,19 +375,18 @@ void CpuProfiler::CodeDeleteEvent(Address from) {
void CpuProfiler::SharedFunctionInfoMoveEvent(Address from, Address to) {
- CpuProfiler* profiler = Isolate::Current()->cpu_profiler();
- profiler->processor_->SharedFunctionInfoMoveEvent(from, to);
+ processor_->SharedFunctionInfoMoveEvent(from, to);
}
void CpuProfiler::GetterCallbackEvent(Name* name, Address entry_point) {
- Isolate::Current()->cpu_profiler()->processor_->CallbackCreateEvent(
+ processor_->CallbackCreateEvent(
Logger::CALLBACK_TAG, "get ", name, entry_point);
}
void CpuProfiler::RegExpCodeCreateEvent(Code* code, String* source) {
- Isolate::Current()->cpu_profiler()->processor_->RegExpCodeCreateEvent(
+ processor_->RegExpCodeCreateEvent(
Logger::REG_EXP_TAG,
"RegExp: ",
source,
@@ -441,13 +396,14 @@ void CpuProfiler::RegExpCodeCreateEvent(Code* code, String* source) {
void CpuProfiler::SetterCallbackEvent(Name* name, Address entry_point) {
- Isolate::Current()->cpu_profiler()->processor_->CallbackCreateEvent(
+ processor_->CallbackCreateEvent(
Logger::CALLBACK_TAG, "set ", name, entry_point);
}
-CpuProfiler::CpuProfiler()
- : profiles_(new CpuProfilesCollection()),
+CpuProfiler::CpuProfiler(Isolate* isolate)
+ : isolate_(isolate),
+ profiles_(new CpuProfilesCollection()),
next_profile_uid_(1),
token_enumerator_(new TokenEnumerator()),
generator_(NULL),
@@ -468,43 +424,41 @@ void CpuProfiler::ResetProfiles() {
profiles_ = new CpuProfilesCollection();
}
-void CpuProfiler::StartCollectingProfile(const char* title) {
- if (profiles_->StartProfiling(title, next_profile_uid_++)) {
+void CpuProfiler::StartProfiling(const char* title, bool record_samples) {
+ if (profiles_->StartProfiling(title, next_profile_uid_++, record_samples)) {
StartProcessorIfNotStarted();
}
processor_->AddCurrentStack();
}
-void CpuProfiler::StartCollectingProfile(String* title) {
- StartCollectingProfile(profiles_->GetName(title));
+void CpuProfiler::StartProfiling(String* title, bool record_samples) {
+ StartProfiling(profiles_->GetName(title), record_samples);
}
void CpuProfiler::StartProcessorIfNotStarted() {
if (processor_ == NULL) {
- Isolate* isolate = Isolate::Current();
-
// Disable logging when using the new implementation.
- saved_logging_nesting_ = isolate->logger()->logging_nesting_;
- isolate->logger()->logging_nesting_ = 0;
+ saved_logging_nesting_ = isolate_->logger()->logging_nesting_;
+ isolate_->logger()->logging_nesting_ = 0;
generator_ = new ProfileGenerator(profiles_);
processor_ = new ProfilerEventsProcessor(generator_);
is_profiling_ = true;
processor_->Start();
// Enumerate stuff we already have in the heap.
- if (isolate->heap()->HasBeenSetUp()) {
+ if (isolate_->heap()->HasBeenSetUp()) {
if (!FLAG_prof_browser_mode) {
bool saved_log_code_flag = FLAG_log_code;
FLAG_log_code = true;
- isolate->logger()->LogCodeObjects();
+ isolate_->logger()->LogCodeObjects();
FLAG_log_code = saved_log_code_flag;
}
- isolate->logger()->LogCompiledFunctions();
- isolate->logger()->LogAccessorCallbacks();
+ isolate_->logger()->LogCompiledFunctions();
+ isolate_->logger()->LogAccessorCallbacks();
}
// Enable stack sampling.
- Sampler* sampler = reinterpret_cast<Sampler*>(isolate->logger()->ticker_);
+ Sampler* sampler = reinterpret_cast<Sampler*>(isolate_->logger()->ticker_);
if (!sampler->IsActive()) {
sampler->Start();
need_to_stop_sampler_ = true;
@@ -514,7 +468,8 @@ void CpuProfiler::StartProcessorIfNotStarted() {
}
-CpuProfile* CpuProfiler::StopCollectingProfile(const char* title) {
+CpuProfile* CpuProfiler::StopProfiling(const char* title) {
+ if (!is_profiling_) return NULL;
const double actual_sampling_rate = generator_->actual_sampling_rate();
StopProcessorIfLastProfile(title);
CpuProfile* result =
@@ -528,8 +483,8 @@ CpuProfile* CpuProfiler::StopCollectingProfile(const char* title) {
}
-CpuProfile* CpuProfiler::StopCollectingProfile(Object* security_token,
- String* title) {
+CpuProfile* CpuProfiler::StopProfiling(Object* security_token, String* title) {
+ if (!is_profiling_) return NULL;
const double actual_sampling_rate = generator_->actual_sampling_rate();
const char* profile_title = profiles_->GetName(title);
StopProcessorIfLastProfile(profile_title);
@@ -544,7 +499,7 @@ void CpuProfiler::StopProcessorIfLastProfile(const char* title) {
void CpuProfiler::StopProcessor() {
- Logger* logger = Isolate::Current()->logger();
+ Logger* logger = isolate_->logger();
Sampler* sampler = reinterpret_cast<Sampler*>(logger->ticker_);
sampler->DecreaseProfilingDepth();
if (need_to_stop_sampler_) {
@@ -562,20 +517,4 @@ void CpuProfiler::StopProcessor() {
}
-void CpuProfiler::SetUp() {
- Isolate* isolate = Isolate::Current();
- if (isolate->cpu_profiler() == NULL) {
- isolate->set_cpu_profiler(new CpuProfiler());
- }
-}
-
-
-void CpuProfiler::TearDown() {
- Isolate* isolate = Isolate::Current();
- if (isolate->cpu_profiler() != NULL) {
- delete isolate->cpu_profiler();
- }
- isolate->set_cpu_profiler(NULL);
-}
-
} } // namespace v8::internal
View
103 src/cpu-profiler.h
@@ -184,84 +184,71 @@ class ProfilerEventsProcessor : public Thread {
unsigned enqueue_order_;
};
-} } // namespace v8::internal
-
-#define PROFILE(isolate, Call) \
- LOG_CODE_EVENT(isolate, Call); \
- do { \
- if (v8::internal::CpuProfiler::is_profiling(isolate)) { \
- v8::internal::CpuProfiler::Call; \
- } \
+#define PROFILE(IsolateGetter, Call) \
+ do { \
+ Isolate* cpu_profiler_isolate = (IsolateGetter); \
+ LOG_CODE_EVENT(cpu_profiler_isolate, Call); \
+ CpuProfiler* cpu_profiler = cpu_profiler_isolate->cpu_profiler(); \
+ if (cpu_profiler->is_profiling()) { \
+ cpu_profiler->Call; \
+ } \
} while (false)
-namespace v8 {
-namespace internal {
-
-
-// TODO(isolates): isolatify this class.
class CpuProfiler {
public:
- static void SetUp();
- static void TearDown();
-
- static void StartProfiling(const char* title);
- static void StartProfiling(String* title);
- static CpuProfile* StopProfiling(const char* title);
- static CpuProfile* StopProfiling(Object* security_token, String* title);
- static int GetProfilesCount();
- static CpuProfile* GetProfile(Object* security_token, int index);
- static CpuProfile* FindProfile(Object* security_token, unsigned uid);
- static void DeleteAllProfiles();
- static void DeleteProfile(CpuProfile* profile);
- static bool HasDetachedProfiles();
+ explicit CpuProfiler(Isolate* isolate);
+ ~CpuProfiler();
+
+ void StartProfiling(const char* title, bool record_samples = false);
+ void StartProfiling(String* title, bool record_samples);
+ CpuProfile* StopProfiling(const char* title);
+ CpuProfile* StopProfiling(Object* security_token, String* title);
+ int GetProfilesCount();
+ CpuProfile* GetProfile(Object* security_token, int index);
+ CpuProfile* FindProfile(Object* security_token, unsigned uid);
+ void DeleteAllProfiles();
+ void DeleteProfile(CpuProfile* profile);
+ bool HasDetachedProfiles();
// Invoked from stack sampler (thread or signal handler.)
- static TickSample* TickSampleEvent(Isolate* isolate);
+ TickSample* TickSampleEvent();
// Must be called via PROFILE macro, otherwise will crash when
// profiling is not enabled.
- static void CallbackEvent(Name* name, Address entry_point);
- static void CodeCreateEvent(Logger::LogEventsAndTags tag,
- Code* code, const char* comment);
- static void CodeCreateEvent(Logger::LogEventsAndTags tag,
- Code* code, Name* name);
- static void CodeCreateEvent(Logger::LogEventsAndTags tag,
- Code* code,
+ void CallbackEvent(Name* name, Address entry_point);
+ void CodeCreateEvent(Logger::LogEventsAndTags tag,
+ Code* code, const char* comment);
+ void CodeCreateEvent(Logger::LogEventsAndTags tag,
+ Code* code, Name* name);
+ void CodeCreateEvent(Logger::LogEventsAndTags tag,
+ Code* code,
SharedFunctionInfo* shared,
Name* name);
- static void CodeCreateEvent(Logger::LogEventsAndTags tag,
- Code* code,
- SharedFunctionInfo* shared,
- String* source, int line);
- static void CodeCreateEvent(Logger::LogEventsAndTags tag,
- Code* code, int args_count);
- static void CodeMovingGCEvent() {}
- static void CodeMoveEvent(Address from, Address to);
- static void CodeDeleteEvent(Address from);
- static void GetterCallbackEvent(Name* name, Address entry_point);
- static void RegExpCodeCreateEvent(Code* code, String* source);
- static void SetterCallbackEvent(Name* name, Address entry_point);
- static void SharedFunctionInfoMoveEvent(Address from, Address to);
-
- static INLINE(bool is_profiling(Isolate* isolate)) {
- CpuProfiler* profiler = isolate->cpu_profiler();
- return profiler != NULL && profiler->is_profiling_;
- }
+ void CodeCreateEvent(Logger::LogEventsAndTags tag,
+ Code* code,
+ SharedFunctionInfo* shared,
+ String* source, int line);
+ void CodeCreateEvent(Logger::LogEventsAndTags tag,
+ Code* code, int args_count);
+ void CodeMovingGCEvent() {}
+ void CodeMoveEvent(Address from, Address to);
+ void CodeDeleteEvent(Address from);
+ void GetterCallbackEvent(Name* name, Address entry_point);
+ void RegExpCodeCreateEvent(Code* code, String* source);
+ void SetterCallbackEvent(Name* name, Address entry_point);
+ void SharedFunctionInfoMoveEvent(Address from, Address to);
+
+ INLINE(bool is_profiling() const) { return is_profiling_; }
private:
- CpuProfiler();
- ~CpuProfiler();
- void StartCollectingProfile(const char* title);
- void StartCollectingProfile(String* title);
void StartProcessorIfNotStarted();
- CpuProfile* StopCollectingProfile(const char* title);
- CpuProfile* StopCollectingProfile(Object* security_token, String* title);
void StopProcessorIfLastProfile(const char* title);
void StopProcessor();
void ResetProfiles();
+ Isolate* isolate_;
CpuProfilesCollection* profiles_;
unsigned next_profile_uid_;
TokenEnumerator* token_enumerator_;
View
103 src/deoptimizer.cc
@@ -1280,29 +1280,37 @@ void Deoptimizer::DoComputeCompiledStubFrame(TranslationIterator* iterator,
}
intptr_t caller_arg_count = 0;
- if (descriptor->stack_parameter_count_ != NULL) {
- caller_arg_count =
- input_->GetRegister(descriptor->stack_parameter_count_->code());
- }
+ bool arg_count_known = descriptor->stack_parameter_count_ == NULL;
// Build the Arguments object for the caller's parameters and a pointer to it.
output_frame_offset -= kPointerSize;
- value = frame_ptr + StandardFrameConstants::kCallerSPOffset +
- (caller_arg_count - 1) * kPointerSize;
- output_frame->SetFrameSlot(output_frame_offset, value);
+ int args_arguments_offset = output_frame_offset;
+ intptr_t the_hole = reinterpret_cast<intptr_t>(
+ isolate_->heap()->the_hole_value());
+ if (arg_count_known) {
+ value = frame_ptr + StandardFrameConstants::kCallerSPOffset +
+ (caller_arg_count - 1) * kPointerSize;
+ } else {
+ value = the_hole;
+ }
+
+ output_frame->SetFrameSlot(args_arguments_offset, value);
if (trace_) {
PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
- V8PRIxPTR " ; args.arguments\n",
- top_address + output_frame_offset, output_frame_offset, value);
+ V8PRIxPTR " ; args.arguments %s\n",
+ top_address + args_arguments_offset, args_arguments_offset, value,
+ arg_count_known ? "" : "(the hole)");
}
output_frame_offset -= kPointerSize;
- value = caller_arg_count;
- output_frame->SetFrameSlot(output_frame_offset, value);
+ int length_frame_offset = output_frame_offset;
+ value = arg_count_known ? caller_arg_count : the_hole;
+ output_frame->SetFrameSlot(length_frame_offset, value);
if (trace_) {
PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
- V8PRIxPTR " ; args.length\n",
- top_address + output_frame_offset, output_frame_offset, value);
+ V8PRIxPTR " ; args.length %s\n",
+ top_address + length_frame_offset, length_frame_offset, value,
+ arg_count_known ? "" : "(the hole)");
}
output_frame_offset -= kPointerSize;
@@ -1321,6 +1329,20 @@ void Deoptimizer::DoComputeCompiledStubFrame(TranslationIterator* iterator,
DoTranslateCommand(iterator, 0, output_frame_offset);
}
+ if (!arg_count_known) {
+ DoTranslateCommand(iterator, 0, length_frame_offset,
+ TRANSLATED_VALUE_IS_NATIVE);
+ caller_arg_count = output_frame->GetFrameSlot(length_frame_offset);
+ value = frame_ptr + StandardFrameConstants::kCallerSPOffset +
+ (caller_arg_count - 1) * kPointerSize;
+ output_frame->SetFrameSlot(args_arguments_offset, value);
+ if (trace_) {
+ PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
+ V8PRIxPTR " ; args.arguments\n",
+ top_address + args_arguments_offset, args_arguments_offset, value);
+ }
+ }
+
ASSERT(0 == output_frame_offset);
// Copy the double registers from the input into the output frame.
@@ -1331,8 +1353,9 @@ void Deoptimizer::DoComputeCompiledStubFrame(TranslationIterator* iterator,
// Compute this frame's PC, state, and continuation.
Code* trampoline = NULL;
- int extra = descriptor->extra_expression_stack_count_;
- StubFailureTrampolineStub(extra).FindCodeInCache(&trampoline, isolate_);
+ StubFunctionMode function_mode = descriptor->function_mode_;
+ StubFailureTrampolineStub(function_mode).FindCodeInCache(&trampoline,
+ isolate_);
ASSERT(trampoline != NULL);
output_frame->SetPc(reinterpret_cast<intptr_t>(
trampoline->instruction_start()));
@@ -1476,12 +1499,25 @@ void Deoptimizer::MaterializeHeapNumbersForDebuggerInspectableFrame(
#endif
+static const char* TraceValueType(bool is_smi, bool is_native) {
+ if (is_native) {
+ return "native";
+ } else if (is_smi) {
+ return "smi";
+ }
+
+ return "heap number";
+}
+
+
void Deoptimizer::DoTranslateCommand(TranslationIterator* iterator,
- int frame_index,
- unsigned output_offset) {
+ int frame_index,
+ unsigned output_offset,
+ DeoptimizerTranslatedValueType value_type) {
disasm::NameConverter converter;
// A GC-safe temporary placeholder that we can put in the output frame.
const intptr_t kPlaceholder = reinterpret_cast<intptr_t>(Smi::FromInt(0));
+ bool is_native = value_type == TRANSLATED_VALUE_IS_NATIVE;
// Ignore commands marked as duplicate and act on the first non-duplicate.
Translation::Opcode opcode =
@@ -1524,7 +1560,9 @@ void Deoptimizer::DoTranslateCommand(TranslationIterator* iterator,
case Translation::INT32_REGISTER: {
int input_reg = iterator->Next();
intptr_t value = input_->GetRegister(input_reg);
- bool is_smi = Smi::IsValid(value);
+ bool is_smi = (value_type == TRANSLATED_VALUE_IS_TAGGED) &&
+ Smi::IsValid(value);
+
if (trace_) {
PrintF(
" 0x%08" V8PRIxPTR ": [top + %d] <- %" V8PRIdPTR " ; %s (%s)\n",
@@ -1532,15 +1570,18 @@ void Deoptimizer::DoTranslateCommand(TranslationIterator* iterator,
output_offset,
value,
converter.NameOfCPURegister(input_reg),
- is_smi ? "smi" : "heap number");
+ TraceValueType(is_smi, is_native));
}
if (is_smi) {
intptr_t tagged_value =
reinterpret_cast<intptr_t>(Smi::FromInt(static_cast<int>(value)));
output_[frame_index]->SetFrameSlot(output_offset, tagged_value);
+ } else if (value_type == TRANSLATED_VALUE_IS_NATIVE) {
+ output_[frame_index]->SetFrameSlot(output_offset, value);
} else {
// We save the untagged value on the side and store a GC-safe
// temporary placeholder in the frame.
+ ASSERT(value_type == TRANSLATED_VALUE_IS_TAGGED);
AddDoubleValue(output_[frame_index]->GetTop() + output_offset,
static_cast<double>(static_cast<int32_t>(value)));
output_[frame_index]->SetFrameSlot(output_offset, kPlaceholder);
@@ -1551,7 +1592,8 @@ void Deoptimizer::DoTranslateCommand(TranslationIterator* iterator,
case Translation::UINT32_REGISTER: {
int input_reg = iterator->Next();
uintptr_t value = static_cast<uintptr_t>(input_->GetRegister(input_reg));
- bool is_smi = (value <= static_cast<uintptr_t>(Smi::kMaxValue));
+ bool is_smi = (value_type == TRANSLATED_VALUE_IS_TAGGED) &&
+ (value <= static_cast<uintptr_t>(Smi::kMaxValue));
if (trace_) {
PrintF(
" 0x%08" V8PRIxPTR ": [top + %d] <- %" V8PRIuPTR
@@ -1560,15 +1602,18 @@ void Deoptimizer::DoTranslateCommand(TranslationIterator* iterator,
output_offset,
value,
converter.NameOfCPURegister(input_reg),
- is_smi ? "smi" : "heap number");
+ TraceValueType(is_smi, is_native));
}
if (is_smi) {
intptr_t tagged_value =
reinterpret_cast<intptr_t>(Smi::FromInt(static_cast<int>(value)));
output_[frame_index]->SetFrameSlot(output_offset, tagged_value);
+ } else if (value_type == TRANSLATED_VALUE_IS_NATIVE) {
+ output_[frame_index]->SetFrameSlot(output_offset, value);
} else {
// We save the untagged value on the side and store a GC-safe
// temporary placeholder in the frame.
+ ASSERT(value_type == TRANSLATED_VALUE_IS_TAGGED);
AddDoubleValue(output_[frame_index]->GetTop() + output_offset,
static_cast<double>(static_cast<uint32_t>(value)));
output_[frame_index]->SetFrameSlot(output_offset, kPlaceholder);
@@ -1617,7 +1662,8 @@ void Deoptimizer::DoTranslateCommand(TranslationIterator* iterator,
unsigned input_offset =
input_->GetOffsetFromSlotIndex(input_slot_index);
intptr_t value = input_->GetFrameSlot(input_offset);
- bool is_smi = Smi::IsValid(value);
+ bool is_smi = (value_type == TRANSLATED_VALUE_IS_TAGGED) &&
+ Smi::IsValid(value);
if (trace_) {
PrintF(" 0x%08" V8PRIxPTR ": ",
output_[frame_index]->GetTop() + output_offset);
@@ -1625,15 +1671,18 @@ void Deoptimizer::DoTranslateCommand(TranslationIterator* iterator,
output_offset,
value,
input_offset,
- is_smi ? "smi" : "heap number");
+ TraceValueType(is_smi, is_native));
}
if (is_smi) {
intptr_t tagged_value =
reinterpret_cast<intptr_t>(Smi::FromInt(static_cast<int>(value)));
output_[frame_index]->SetFrameSlot(output_offset, tagged_value);
+ } else if (value_type == TRANSLATED_VALUE_IS_NATIVE) {
+ output_[frame_index]->SetFrameSlot(output_offset, value);
} else {
// We save the untagged value on the side and store a GC-safe
// temporary placeholder in the frame.
+ ASSERT(value_type == TRANSLATED_VALUE_IS_TAGGED);
AddDoubleValue(output_[frame_index]->GetTop() + output_offset,
static_cast<double>(static_cast<int32_t>(value)));
output_[frame_index]->SetFrameSlot(output_offset, kPlaceholder);
@@ -1647,7 +1696,8 @@ void Deoptimizer::DoTranslateCommand(TranslationIterator* iterator,
input_->GetOffsetFromSlotIndex(input_slot_index);
uintptr_t value =
static_cast<uintptr_t>(input_->GetFrameSlot(input_offset));
- bool is_smi = (value <= static_cast<uintptr_t>(Smi::kMaxValue));
+ bool is_smi = (value_type == TRANSLATED_VALUE_IS_TAGGED) &&
+ (value <= static_cast<uintptr_t>(Smi::kMaxValue));
if (trace_) {
PrintF(" 0x%08" V8PRIxPTR ": ",
output_[frame_index]->GetTop() + output_offset);
@@ -1655,15 +1705,18 @@ void Deoptimizer::DoTranslateCommand(TranslationIterator* iterator,
output_offset,
value,
input_offset,
- is_smi ? "smi" : "heap number");
+ TraceValueType(is_smi, is_native));
}
if (is_smi) {
intptr_t tagged_value =
reinterpret_cast<intptr_t>(Smi::FromInt(static_cast<int>(value)));
output_[frame_index]->SetFrameSlot(output_offset, tagged_value);
+ } else if (value_type == TRANSLATED_VALUE_IS_NATIVE) {
+ output_[frame_index]->SetFrameSlot(output_offset, value);
} else {
// We save the untagged value on the side and store a GC-safe
// temporary placeholder in the frame.
+ ASSERT(value_type == TRANSLATED_VALUE_IS_TAGGED);
AddDoubleValue(output_[frame_index]->GetTop() + output_offset,
static_cast<double>(static_cast<uint32_t>(value)));
output_[frame_index]->SetFrameSlot(output_offset, kPlaceholder);
View
12 src/deoptimizer.h
@@ -356,9 +356,17 @@ class Deoptimizer : public Malloced {
bool is_setter_stub_frame);
void DoComputeCompiledStubFrame(TranslationIterator* iterator,
int frame_index);
+
+ enum DeoptimizerTranslatedValueType {
+ TRANSLATED_VALUE_IS_NATIVE,
+ TRANSLATED_VALUE_IS_TAGGED
+ };
+
void DoTranslateCommand(TranslationIterator* iterator,
- int frame_index,
- unsigned output_offset);
+ int frame_index,
+ unsigned output_offset,
+ DeoptimizerTranslatedValueType value_type = TRANSLATED_VALUE_IS_TAGGED);
+
// Translate a command for OSR. Updates the input offset to be used for
// the next command. Returns false if translation of the command failed
// (e.g., a number conversion failed) and may or may not have updated the
View
9 src/elements-kind.h
@@ -110,10 +110,15 @@ inline bool IsFastDoubleElementsKind(ElementsKind kind) {
}
+inline bool IsExternalFloatOrDoubleElementsKind(ElementsKind kind) {
+ return kind == EXTERNAL_DOUBLE_ELEMENTS ||
+ kind == EXTERNAL_FLOAT_ELEMENTS;
+}
+
+
inline bool IsDoubleOrFloatElementsKind(ElementsKind kind) {
return IsFastDoubleElementsKind(kind) ||
- kind == EXTERNAL_DOUBLE_ELEMENTS ||
- kind == EXTERNAL_FLOAT_ELEMENTS;
+ IsExternalFloatOrDoubleElementsKind(kind);
}
View
3  src/flag-definitions.h
@@ -148,6 +148,8 @@ DEFINE_bool(harmony_collections, false,
"enable harmony collections (sets, maps, and weak maps)")
DEFINE_bool(harmony_observation, false,
"enable harmony object observation (implies harmony collections")
+DEFINE_bool(harmony_typed_arrays, false,
+ "enable harmony typed arrays")
DEFINE_bool(harmony, false, "enable all harmony features (except typeof)")
DEFINE_implication(harmony, harmony_scoping)
DEFINE_implication(harmony, harmony_modules)
@@ -157,6 +159,7 @@ DEFINE_implication(harmony, harmony_collections)
DEFINE_implication(harmony, harmony_observation)
DEFINE_implication(harmony_modules, harmony_scoping)
DEFINE_implication(harmony_observation, harmony_collections)
+DEFINE_implication(harmony, harmony_typed_arrays)
// Flags for experimental implementation features.
DEFINE_bool(packed_arrays, true, "optimizes arrays that have no holes")
View
23 src/frames.cc
@@ -1311,18 +1311,19 @@ Address StubFailureTrampolineFrame::GetCallerStackPointer() const {
Code* StubFailureTrampolineFrame::unchecked_code() const {
- int i = 0;
- for (; i <= StubFailureTrampolineStub::kMaxExtraExpressionStackCount; ++i) {
- Code* trampoline;
- StubFailureTrampolineStub(i).FindCodeInCache(&trampoline, isolate());
- ASSERT(trampoline != NULL);
- Address current_pc = pc();
- Address code_start = trampoline->instruction_start();
- Address code_end = code_start + trampoline->instruction_size();
- if (code_start <= current_pc && current_pc < code_end) {
- return trampoline;
- }
+ Code* trampoline;
+ StubFailureTrampolineStub(NOT_JS_FUNCTION_STUB_MODE).
+ FindCodeInCache(&trampoline, isolate());
+ if (trampoline->contains(pc())) {
+ return trampoline;
}
+
+ StubFailureTrampolineStub(JS_FUNCTION_STUB_MODE).
+ FindCodeInCache(&trampoline, isolate());
+ if (trampoline->contains(pc())) {
+ return trampoline;
+ }
+
UNREACHABLE();
return NULL;
}
View
125 src/heap-profiler.cc
@@ -44,72 +44,13 @@ HeapProfiler::~HeapProfiler() {
}
-void HeapProfiler::ResetSnapshots() {
+void HeapProfiler::DeleteAllSnapshots() {
Heap* the_heap = heap();
delete snapshots_;
snapshots_ = new HeapSnapshotsCollection(the_heap);
}
-void HeapProfiler::SetUp() {
- Isolate* isolate = Isolate::Current();
- if (isolate->heap_profiler() == NULL) {
- isolate->set_heap_profiler(new HeapProfiler(isolate->heap()));
- }
-}
-
-
-void HeapProfiler::TearDown() {
- Isolate* isolate = Isolate::Current();
- delete isolate->heap_profiler();
- isolate->set_heap_profiler(NULL);
-}
-
-
-HeapSnapshot* HeapProfiler::TakeSnapshot(
- const char* name,
- int type,
- v8::ActivityControl* control,
- v8::HeapProfiler::ObjectNameResolver* resolver) {
- ASSERT(Isolate::Current()->heap_profiler() != NULL);
- return Isolate::Current()->heap_profiler()->TakeSnapshotImpl(name,
- type,
- control,
- resolver);
-}
-
-
-HeapSnapshot* HeapProfiler::TakeSnapshot(
- String* name,
- int type,
- v8::ActivityControl* control,
- v8::HeapProfiler::ObjectNameResolver* resolver) {
- ASSERT(Isolate::Current()->heap_profiler() != NULL);
- return Isolate::Current()->heap_profiler()->TakeSnapshotImpl(name,
- type,
- control,
- resolver);
-}
-
-
-void HeapProfiler::StartHeapObjectsTracking() {
- ASSERT(Isolate::Current()->heap_profiler() != NULL);
- Isolate::Current()->heap_profiler()->StartHeapObjectsTrackingImpl();
-}
-
-
-void HeapProfiler::StopHeapObjectsTracking() {
- ASSERT(Isolate::Current()->heap_profiler() != NULL);
- Isolate::Current()->heap_profiler()->StopHeapObjectsTrackingImpl();
-}
-
-
-SnapshotObjectId HeapProfiler::PushHeapObjectsStats(v8::OutputStream* stream) {
- ASSERT(Isolate::Current()->heap_profiler() != NULL);
- return Isolate::Current()->heap_profiler()->PushHeapObjectsStatsImpl(stream);
-}
-
-
void HeapProfiler::DefineWrapperClass(
uint16_t class_id, v8::HeapProfiler::WrapperInfoCallback callback) {
ASSERT(class_id != v8::HeapProfiler::kPersistentHandleNoClassId);
@@ -129,99 +70,69 @@ v8::RetainedObjectInfo* HeapProfiler::ExecuteWrapperClassCallback(
}
-HeapSnapshot* HeapProfiler::TakeSnapshotImpl(
+HeapSnapshot* HeapProfiler::TakeSnapshot(
const char* name,
- int type,
v8::ActivityControl* control,
v8::HeapProfiler::ObjectNameResolver* resolver) {
- HeapSnapshot::Type s_type = static_cast<HeapSnapshot::Type>(type);
- HeapSnapshot* result =
- snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++);
- bool generation_completed = true;
- switch (s_type) {
- case HeapSnapshot::kFull: {
- HeapSnapshotGenerator generator(result, control, resolver, heap());
- generation_completed = generator.GenerateSnapshot();
- break;
+ HeapSnapshot* result = snapshots_->NewSnapshot(name, next_snapshot_uid_++);
+ {
+ HeapSnapshotGenerator generator(result, control, resolver, heap());
+ if (!generator.GenerateSnapshot()) {
+ delete result;
+ result = NULL;
}
- default:
- UNREACHABLE();
- }
- if (!generation_completed) {
- delete result;
- result = NULL;
}
snapshots_->SnapshotGenerationFinished(result);
return result;
}
-HeapSnapshot* HeapProfiler::TakeSnapshotImpl(
+HeapSnapshot* HeapProfiler::TakeSnapshot(
String* name,
- int type,
v8::ActivityControl* control,
v8::HeapProfiler::ObjectNameResolver* resolver) {
- return TakeSnapshotImpl(snapshots_->names()->GetName(name), type, control,
- resolver);
+ return TakeSnapshot(snapshots_->names()->GetName(name), control, resolver);
}
-void HeapProfiler::StartHeapObjectsTrackingImpl() {
+void HeapProfiler::StartHeapObjectsTracking() {
snapshots_->StartHeapObjectsTracking();
}
-SnapshotObjectId HeapProfiler::PushHeapObjectsStatsImpl(OutputStream* stream) {
+SnapshotObjectId HeapProfiler::PushHeapObjectsStats(OutputStream* stream) {
return snapshots_->PushHeapObjectsStats(stream);
}
-void HeapProfiler::StopHeapObjectsTrackingImpl() {
+void HeapProfiler::StopHeapObjectsTracking() {
snapshots_->StopHeapObjectsTracking();
}
size_t HeapProfiler::GetMemorySizeUsedByProfiler() {
- HeapProfiler* profiler = Isolate::Current()->heap_profiler();
- ASSERT(profiler != NULL);
- size_t size = profiler->snapshots_->GetUsedMemorySize();
- return size;
+ return snapshots_->GetUsedMemorySize();
}
int HeapProfiler::GetSnapshotsCount() {
- HeapProfiler* profiler = Isolate::Current()->heap_profiler();
- ASSERT(profiler != NULL);
- return profiler->snapshots_->snapshots()->length();
+ return snapshots_->snapshots()->length();
}
HeapSnapshot* HeapProfiler::GetSnapshot(int index) {
- HeapProfiler* profiler = Isolate::Current()->heap_profiler();
- ASSERT(profiler != NULL);
- return profiler->snapshots_->snapshots()->at(index);
+ return snapshots_->snapshots()->at(index);
}
HeapSnapshot* HeapProfiler::FindSnapshot(unsigned uid) {
- HeapProfiler* profiler = Isolate::Current()->heap_profiler();
- ASSERT(profiler != NULL);
- return profiler->snapshots_->GetSnapshot(uid);
+ return snapshots_->GetSnapshot(uid);
}
SnapshotObjectId HeapProfiler::GetSnapshotObjectId(Handle<Object> obj) {
if (!obj->IsHeapObject())
return v8::HeapProfiler::kUnknownObjectId;
- HeapProfiler* profiler = Isolate::Current()->heap_profiler();
- ASSERT(profiler != NULL);
- return profiler->snapshots_->FindObjectId(HeapObject::cast(*obj)->address());
-}
-
-
-void HeapProfiler::DeleteAllSnapshots() {
- HeapProfiler* profiler = Isolate::Current()->heap_profiler();
- ASSERT(profiler != NULL);
- profiler->ResetSnapshots();
+ return snapshots_->FindObjectId(HeapObject::cast(*obj)->address());
}
View
46 src/heap-profiler.h
@@ -46,30 +46,28 @@ class HeapSnapshotsCollection;
class HeapProfiler {
public:
- static void SetUp();
- static void TearDown();
+ explicit HeapProfiler(Heap* heap);
+ ~HeapProfiler();
- static size_t GetMemorySizeUsedByProfiler();
+ size_t GetMemorySizeUsedByProfiler();
- static HeapSnapshot* TakeSnapshot(
+ HeapSnapshot* TakeSnapshot(