aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBo Liu <boliu@google.com>2014-07-29 11:13:58 -0700
committerBo Liu <boliu@google.com>2014-07-29 11:13:58 -0700
commit76ffc0d6eb9ce76217df54e1d004cccf0924c3e9 (patch)
treeae00999d53bd25cbd1f48a16cc8fa4bb657c4b02
parentd4205b7f94e015214bb2fdd95bb32342c5b62f4b (diff)
parentfdc3c5570b34908e22f3fe48be77846ca995a64f (diff)
downloadv8-76ffc0d6eb9ce76217df54e1d004cccf0924c3e9.tar.gz
Merge v8 from https://chromium.googlesource.com/a/external/v8.git at fdc3c5570b34908e22f3fe48be77846ca995a64f
This commit was generated by merge_from_chromium.py. Change-Id: Ic2d006d89f41430010e1daa359108b4d38628223
-rw-r--r--include/v8.h22
-rw-r--r--src/api.cc24
-rw-r--r--src/counters.cc32
-rw-r--r--src/counters.h4
-rw-r--r--src/d8.cc10
-rw-r--r--src/d8.h2
-rw-r--r--src/version.cc2
-rw-r--r--test/cctest/test-api.cc15
8 files changed, 98 insertions, 13 deletions
diff --git a/include/v8.h b/include/v8.h
index 1db14733a..4e8556162 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -4391,6 +4391,21 @@ class V8_EXPORT Isolate {
*/
bool WillAutorunMicrotasks() const;
+ /**
+ * Enables the host application to provide a mechanism for recording
+ * statistics counters.
+ */
+ void SetCounterFunction(CounterLookupCallback);
+
+ /**
+ * Enables the host application to provide a mechanism for recording
+ * histograms. The CreateHistogram function returns a
+ * histogram which will later be passed to the AddHistogramSample
+ * function.
+ */
+ void SetCreateHistogramFunction(CreateHistogramCallback);
+ void SetAddHistogramSampleFunction(AddHistogramSampleCallback);
+
private:
template<class K, class V, class Traits> friend class PersistentValueMap;
@@ -4687,6 +4702,8 @@ class V8_EXPORT V8 {
/**
* Enables the host application to provide a mechanism for recording
* statistics counters.
+ *
+ * Deprecated, use Isolate::SetCounterFunction instead.
*/
static void SetCounterFunction(CounterLookupCallback);
@@ -4695,8 +4712,13 @@ class V8_EXPORT V8 {
* histograms. The CreateHistogram function returns a
* histogram which will later be passed to the AddHistogramSample
* function.
+ *
+ * Deprecated, use Isolate::SetCreateHistogramFunction instead.
+ * Isolate::SetAddHistogramSampleFunction instead.
*/
static void SetCreateHistogramFunction(CreateHistogramCallback);
+
+ /** Deprecated, use Isolate::SetAddHistogramSampleFunction instead. */
static void SetAddHistogramSampleFunction(AddHistogramSampleCallback);
/** Callback function for reporting failed access checks.*/
diff --git a/src/api.cc b/src/api.cc
index 9758228b2..bf54d0b25 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -6707,6 +6707,30 @@ bool Isolate::WillAutorunMicrotasks() const {
}
+void Isolate::SetCounterFunction(CounterLookupCallback callback) {
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
+ isolate->stats_table()->SetCounterFunction(callback);
+ isolate->InitializeLoggingAndCounters();
+ isolate->counters()->ResetCounters();
+}
+
+
+void Isolate::SetCreateHistogramFunction(CreateHistogramCallback callback) {
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
+ isolate->stats_table()->SetCreateHistogramFunction(callback);
+ isolate->InitializeLoggingAndCounters();
+ isolate->counters()->ResetHistograms();
+}
+
+
+void Isolate::SetAddHistogramSampleFunction(
+ AddHistogramSampleCallback callback) {
+ reinterpret_cast<i::Isolate*>(this)
+ ->stats_table()
+ ->SetAddHistogramSampleFunction(callback);
+}
+
+
String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj)
: str_(NULL), length_(0) {
i::Isolate* isolate = i::Isolate::Current();
diff --git a/src/counters.cc b/src/counters.cc
index 42b0574b3..cdff8877d 100644
--- a/src/counters.cc
+++ b/src/counters.cc
@@ -109,6 +109,38 @@ Counters::Counters(Isolate* isolate) {
}
+void Counters::ResetCounters() {
+#define SC(name, caption) name##_.Reset();
+ STATS_COUNTER_LIST_1(SC)
+ STATS_COUNTER_LIST_2(SC)
+#undef SC
+
+#define SC(name) \
+ count_of_##name##_.Reset(); \
+ size_of_##name##_.Reset();
+ INSTANCE_TYPE_LIST(SC)
+#undef SC
+
+#define SC(name) \
+ count_of_CODE_TYPE_##name##_.Reset(); \
+ size_of_CODE_TYPE_##name##_.Reset();
+ CODE_KIND_LIST(SC)
+#undef SC
+
+#define SC(name) \
+ count_of_FIXED_ARRAY_##name##_.Reset(); \
+ size_of_FIXED_ARRAY_##name##_.Reset();
+ FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(SC)
+#undef SC
+
+#define SC(name) \
+ count_of_CODE_AGE_##name##_.Reset(); \
+ size_of_CODE_AGE_##name##_.Reset();
+ CODE_AGE_LIST_COMPLETE(SC)
+#undef SC
+}
+
+
void Counters::ResetHistograms() {
#define HT(name, caption) name##_.Reset();
HISTOGRAM_TIMER_LIST(HT)
diff --git a/src/counters.h b/src/counters.h
index f7ff36b75..a7d00dcc8 100644
--- a/src/counters.h
+++ b/src/counters.h
@@ -143,6 +143,9 @@ class StatsCounter {
return loc;
}
+ // Reset the cached internal pointer.
+ void Reset() { lookup_done_ = false; }
+
protected:
// Returns the cached address of this counter location.
int* GetPtr() {
@@ -629,6 +632,7 @@ class Counters {
stats_counter_count
};
+ void ResetCounters();
void ResetHistograms();
private:
diff --git a/src/d8.cc b/src/d8.cc
index 03356e15a..661307f0d 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -665,7 +665,7 @@ Counter* CounterCollection::GetNextCounter() {
}
-void Shell::MapCounters(const char* name) {
+void Shell::MapCounters(v8::Isolate* isolate, const char* name) {
counters_file_ = i::OS::MemoryMappedFile::create(
name, sizeof(CounterCollection), &local_counters_);
void* memory = (counters_file_ == NULL) ?
@@ -675,9 +675,9 @@ void Shell::MapCounters(const char* name) {
Exit(1);
}
counters_ = static_cast<CounterCollection*>(memory);
- V8::SetCounterFunction(LookupCounter);
- V8::SetCreateHistogramFunction(CreateHistogram);
- V8::SetAddHistogramSampleFunction(AddHistogramSample);
+ isolate->SetCounterFunction(LookupCounter);
+ isolate->SetCreateHistogramFunction(CreateHistogram);
+ isolate->SetAddHistogramSampleFunction(AddHistogramSample);
}
@@ -887,7 +887,7 @@ void Shell::Initialize(Isolate* isolate) {
Shell::counter_map_ = new CounterMap();
// Set up counters
if (i::StrLength(i::FLAG_map_counters) != 0)
- MapCounters(i::FLAG_map_counters);
+ MapCounters(isolate, i::FLAG_map_counters);
if (i::FLAG_dump_counters || i::FLAG_track_gc_object_stats) {
V8::SetCounterFunction(LookupCounter);
V8::SetCreateHistogramFunction(CreateHistogram);
diff --git a/src/d8.h b/src/d8.h
index bd70c8e78..143eabb8a 100644
--- a/src/d8.h
+++ b/src/d8.h
@@ -265,7 +265,7 @@ class Shell : public i::AllStatic {
int max,
size_t buckets);
static void AddHistogramSample(void* histogram, int sample);
- static void MapCounters(const char* name);
+ static void MapCounters(v8::Isolate* isolate, const char* name);
static Local<Object> DebugMessageDetails(Isolate* isolate,
Handle<String> message);
diff --git a/src/version.cc b/src/version.cc
index 1f2191728..21200e71c 100644
--- a/src/version.cc
+++ b/src/version.cc
@@ -35,7 +35,7 @@
#define MAJOR_VERSION 3
#define MINOR_VERSION 27
#define BUILD_NUMBER 34
-#define PATCH_LEVEL 6
+#define PATCH_LEVEL 7
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
#define IS_CANDIDATE_VERSION 0
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index d1f25def5..7fc80b3a9 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -19545,15 +19545,15 @@ class InitDefaultIsolateThread : public v8::internal::Thread {
break;
case SetCounterFunction:
- v8::V8::SetCounterFunction(NULL);
+ CcTest::isolate()->SetCounterFunction(NULL);
break;
case SetCreateHistogramFunction:
- v8::V8::SetCreateHistogramFunction(NULL);
+ CcTest::isolate()->SetCreateHistogramFunction(NULL);
break;
case SetAddHistogramSampleFunction:
- v8::V8::SetAddHistogramSampleFunction(NULL);
+ CcTest::isolate()->SetAddHistogramSampleFunction(NULL);
break;
}
isolate->Exit();
@@ -20904,6 +20904,7 @@ TEST(RunMicrotasksWithoutEnteringContext) {
}
+#ifdef DEBUG
static int probes_counter = 0;
static int misses_counter = 0;
static int updates_counter = 0;
@@ -20933,11 +20934,10 @@ static const char* kMegamorphicTestProgram =
" fooify(a);"
" fooify(b);"
"}";
+#endif
static void StubCacheHelper(bool primary) {
- V8::SetCounterFunction(LookupCounter);
- USE(kMegamorphicTestProgram);
#ifdef DEBUG
i::FLAG_native_code_counters = true;
if (primary) {
@@ -20947,6 +20947,7 @@ static void StubCacheHelper(bool primary) {
}
i::FLAG_crankshaft = false;
LocalContext env;
+ env->GetIsolate()->SetCounterFunction(LookupCounter);
v8::HandleScope scope(env->GetIsolate());
int initial_probes = probes_counter;
int initial_misses = misses_counter;
@@ -20976,6 +20977,7 @@ TEST(PrimaryStubCache) {
}
+#ifdef DEBUG
static int cow_arrays_created_runtime = 0;
@@ -20985,13 +20987,14 @@ static int* LookupCounterCOWArrays(const char* name) {
}
return NULL;
}
+#endif
TEST(CheckCOWArraysCreatedRuntimeCounter) {
- V8::SetCounterFunction(LookupCounterCOWArrays);
#ifdef DEBUG
i::FLAG_native_code_counters = true;
LocalContext env;
+ env->GetIsolate()->SetCounterFunction(LookupCounterCOWArrays);
v8::HandleScope scope(env->GetIsolate());
int initial_cow_arrays = cow_arrays_created_runtime;
CompileRun("var o = [1, 2, 3];");