Permalink
Browse files

[counters] remove "override mistake" use counters

v8::Isolate::kAttemptOverrideReadOnlyOnPrototypeSloppy and
v8::Isolate::kAttemptOverrideReadOnlyOnPrototypeStrict are no longer
incremented.

BUG=v8:8175
R=gsathya@chromium.org, littledan@chromium.org

Change-Id: Ia5f8f9226a54d88c15a3c3b4a5941d774eb1834a
Reviewed-on: https://chromium-review.googlesource.com/c/1417381
Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
Commit-Queue: Caitlin Potter <caitp@igalia.com>
Cr-Commit-Position: refs/heads/master@{#58934}
  • Loading branch information...
caitp authored and Commit Bot committed Jan 17, 2019
1 parent 242fd7c commit a62c96a014d76db9ff6aa67f28052630a5f80945
Showing with 0 additions and 93 deletions.
  1. +0 −9 src/objects.cc
  2. +0 −84 test/cctest/test-usecounters.cc
@@ -5429,15 +5429,6 @@ Maybe<bool> Object::CannotCreateProperty(Isolate* isolate,
Maybe<bool> Object::WriteToReadOnlyProperty(LookupIterator* it,
Handle<Object> value,
ShouldThrow should_throw) {
if (it->IsFound() && !it->HolderIsReceiver()) {
// "Override mistake" attempted, record a use count to track this per
// v8:8175
v8::Isolate::UseCounterFeature feature =
should_throw == kThrowOnError
? v8::Isolate::kAttemptOverrideReadOnlyOnPrototypeStrict
: v8::Isolate::kAttemptOverrideReadOnlyOnPrototypeSloppy;
it->isolate()->CountUsage(feature);
}
return WriteToReadOnlyProperty(it->isolate(), it->GetReceiver(),
it->GetName(), value, should_throw);
}
@@ -81,90 +81,6 @@ TEST(AtomicsWakeAndAtomicsNotify) {
CHECK_EQ(1, use_counts[v8::Isolate::kAtomicsNotify]);
}

TEST(OverrideReadOnlyPropertyOnPrototype) {
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);
using Isolate = v8::Isolate;

// Initial setup
CompileRun(
"Object.defineProperty(Object.prototype, 'readonly', "
"{ enumerable: true, configurable: true, writable: false, "
" value: 'readonly' });");
CHECK_EQ(0, use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeSloppy]);
CHECK_EQ(0, use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeStrict]);

// StoreIC Sloppy
CompileRun(
"function sloppy() { let sloppy = {}; sloppy.readonly = 'override'; }"
"sloppy();");
CHECK_EQ(1, use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeSloppy]);
CHECK_EQ(0, use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeStrict]);
use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeSloppy] = 0;
use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeStrict] = 0;

// StoreIC Sloppy (one-shot)
CompileRun("let sloppyob = {}; sloppyob.readonly = 'override';");
CHECK_EQ(1, use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeSloppy]);
CHECK_EQ(0, use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeStrict]);
use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeSloppy] = 0;
use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeStrict] = 0;

// StoreIC Strict
{
v8::TryCatch try_catch(isolate);
CompileRun(
"function strict() {"
" 'use strict'; let strict = {}; strict.readonly = 'override';"
"}"
"strict();");
CHECK_EQ(0, use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeSloppy]);
CHECK_EQ(1, use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeStrict]);
CHECK(try_catch.HasCaught());
}
use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeSloppy] = 0;
use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeStrict] = 0;

// StoreIC Strict (one-shot)
{
v8::TryCatch try_catch(isolate);
CompileRun(
"'use strict';"
"let strictob = {}; strictob.readonly = 'override';");
CHECK_EQ(0, use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeSloppy]);
CHECK_EQ(1, use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeStrict]);
CHECK(try_catch.HasCaught());
}
use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeSloppy] = 0;
use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeStrict] = 0;

// KeyedStoreIC Sloppy
CompileRun(
"function sloppy2() { let sloppy = {}; sloppy['readonly'] = 'override'; }"
"sloppy2();");
CHECK_EQ(1, use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeSloppy]);
CHECK_EQ(0, use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeStrict]);
use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeSloppy] = 0;
use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeStrict] = 0;

// KeyedStoreIC Strict
{
v8::TryCatch try_catch(isolate);
CompileRun(
"function strict2() {"
" 'use strict'; let strict = {}; strict['readonly'] = 'override';"
"}"
"strict2();");
CHECK_EQ(0, use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeSloppy]);
CHECK_EQ(1, use_counts[Isolate::kAttemptOverrideReadOnlyOnPrototypeStrict]);
CHECK(try_catch.HasCaught());
}
}

TEST(RegExpMatchIsTrueishOnNonJSRegExp) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);

0 comments on commit a62c96a

Please sign in to comment.