Commit d521a1e2 authored by Natalie Silvanovich's avatar Natalie Silvanovich Committed by Commit Bot

Adding index accessor counter

Change-Id: I7e833c3b06cfb3ff9eda663c2bee4981013744b0

Adding index accessor counter

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: Ic353c11fa0f430537819387d17eedeec5466d9cc
Bug: 
Reviewed-on: https://chromium-review.googlesource.com/741169Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Natalie Silvanovich <natashenka@google.com>
Cr-Commit-Position: refs/heads/master@{#49061}
parent ed1a31af
......@@ -7053,6 +7053,7 @@ class V8_EXPORT Isolate {
kConstructorNonUndefinedPrimitiveReturn = 39,
kLabeledExpressionStatement = 40,
kLineOrParagraphSeparatorAsLineTerminator = 41,
kIndexAccessor = 42,
// If you add new values here, you'll also need to update Chromium's:
// UseCounter.h, V8PerIsolateData.cpp, histograms.xml
......
......@@ -630,6 +630,7 @@ void LookupIterator::TransitionToAccessorPair(Handle<Object> pair,
if (IsElement()) {
// TODO(verwaest): Move code into the element accessor.
isolate_->CountUsage(v8::Isolate::kIndexAccessor);
Handle<SeededNumberDictionary> dictionary =
JSObject::NormalizeElements(receiver);
......
......@@ -6775,7 +6775,6 @@ MaybeHandle<Object> JSReceiver::DefineProperties(Isolate* isolate,
return object;
}
// static
Maybe<bool> JSReceiver::DefineOwnProperty(Isolate* isolate,
Handle<JSReceiver> object,
......
......@@ -142,6 +142,55 @@ TEST(LabeledExpressionStatement) {
CHECK_EQ(2, use_counts[v8::Isolate::kLabeledExpressionStatement]);
}
TEST(IndexAccessorUseCount) {
i::FLAG_harmony_strict_legacy_accessor_builtins = false;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
LocalContext env;
int use_counts[v8::Isolate::kUseCounterFeatureCount] = {};
global_use_counts = use_counts;
CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
// Adding accessor to named property does not increment kIndexAccessor
CompileRun(
"var a = {};"
"function dummy(){}"
"Object.defineProperty(a, 'test', { get: dummy, set: dummy });");
CHECK_EQ(0, use_counts[v8::Isolate::kIndexAccessor]);
// Setting index to value does not increment kIndexAccessor
CompileRun(
"var a = {};"
"Object.defineProperty(a, '0', { value: 0 });");
CHECK_EQ(0, use_counts[v8::Isolate::kIndexAccessor]);
// Non-integer number index not increment kIndexAccessor
CompileRun(
"var a = {};"
"Object.defineProperty(a, '2.5', { value: 0 });");
CHECK_EQ(0, use_counts[v8::Isolate::kIndexAccessor]);
// Setting index accessor increments count
CompileRun(
"var a = {};"
"function dummy(){}"
"Object.defineProperty(a, '0', { get : dummy, set : dummy });");
CHECK_EQ(1, use_counts[v8::Isolate::kIndexAccessor]);
// Setting index accessor on array increments count
CompileRun(
"var a = [];"
"function dummy(){}"
"Object.defineProperty(a, '0', { get : dummy, set : dummy });");
CHECK_EQ(2, use_counts[v8::Isolate::kIndexAccessor]);
// __defineGetter__ increments count
CompileRun(
"var a = [];"
"function dummy(){}"
"a.__defineGetter__('0', dummy);");
CHECK_EQ(3, use_counts[v8::Isolate::kIndexAccessor]);
}
} // namespace test_usecounters
} // namespace internal
} // namespace v8
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment