[es6] Remove left-overs from Function.prototype.toMethod.
The actual Function.prototype.toMethod was removed some time already,
but there were some stuff (esp. %ToMethod) left in the tree, including
tests for %ToMethod. This code (and esp. the tests) cause trouble in
the process of moving bound functions away from JSFunction; so since
the code is unused anyway, we can as well remove it.
The original removal of Function.prototype.toMethod was in February
2015 in 68e4897586
.
R=jarin@chromium.org
BUG=v8:3330
LOG=n
Review URL: https://codereview.chromium.org/1366063002
Cr-Commit-Position: refs/heads/master@{#30925}
This commit is contained in:
parent
bd35b54d82
commit
ff2c9eace4
@ -10134,30 +10134,6 @@ void JSFunction::AttemptConcurrentOptimization() {
|
||||
}
|
||||
|
||||
|
||||
Handle<JSFunction> JSFunction::CloneClosure(Handle<JSFunction> function) {
|
||||
Isolate* isolate = function->GetIsolate();
|
||||
Handle<Map> map(function->map());
|
||||
Handle<SharedFunctionInfo> shared(function->shared());
|
||||
Handle<Context> context(function->context());
|
||||
Handle<JSFunction> clone =
|
||||
isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context);
|
||||
|
||||
if (shared->bound()) {
|
||||
clone->set_function_bindings(function->function_bindings());
|
||||
}
|
||||
|
||||
// In typical case, __proto__ of ``function`` is the default Function
|
||||
// prototype, which means that SetPrototype below is a no-op.
|
||||
// In rare cases when that is not true, we mutate the clone's __proto__.
|
||||
Handle<Object> original_prototype(map->prototype(), isolate);
|
||||
if (*original_prototype != clone->map()->prototype()) {
|
||||
JSObject::SetPrototype(clone, original_prototype, false).Assert();
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
||||
void SharedFunctionInfo::AddSharedCodeToOptimizedCodeMap(
|
||||
Handle<SharedFunctionInfo> shared, Handle<Code> code) {
|
||||
Isolate* isolate = shared->GetIsolate();
|
||||
|
@ -7141,11 +7141,6 @@ class JSFunction: public JSObject {
|
||||
static void SetInstancePrototype(Handle<JSFunction> function,
|
||||
Handle<Object> value);
|
||||
|
||||
// Creates a new closure for the fucntion with the same bindings,
|
||||
// bound values, and prototype. An equivalent of spec operations
|
||||
// ``CloneMethod`` and ``CloneBoundFunction``.
|
||||
static Handle<JSFunction> CloneClosure(Handle<JSFunction> function);
|
||||
|
||||
// After prototype is removed, it will not be created when accessed, and
|
||||
// [[Construct]] from this function will not be allowed.
|
||||
bool RemovePrototype();
|
||||
|
@ -74,19 +74,6 @@ RUNTIME_FUNCTION(Runtime_ThrowIfStaticPrototype) {
|
||||
}
|
||||
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_ToMethod) {
|
||||
HandleScope scope(isolate);
|
||||
DCHECK(args.length() == 2);
|
||||
CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
|
||||
CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
|
||||
Handle<JSFunction> clone = JSFunction::CloneClosure(fun);
|
||||
Handle<Symbol> home_object_symbol(isolate->factory()->home_object_symbol());
|
||||
JSObject::SetOwnPropertyIgnoreAttributes(clone, home_object_symbol,
|
||||
home_object, DONT_ENUM).Assert();
|
||||
return *clone;
|
||||
}
|
||||
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) {
|
||||
DCHECK(args.length() == 0);
|
||||
return isolate->heap()->home_object_symbol();
|
||||
|
@ -80,7 +80,6 @@ namespace internal {
|
||||
F(ThrowArrayNotSubclassableError, 0, 1) \
|
||||
F(ThrowStaticPrototypeError, 0, 1) \
|
||||
F(ThrowIfStaticPrototype, 1, 1) \
|
||||
F(ToMethod, 2, 1) \
|
||||
F(HomeObjectSymbol, 0, 1) \
|
||||
F(DefineClass, 5, 1) \
|
||||
F(FinalizeClassDefinition, 2, 1) \
|
||||
|
@ -8792,60 +8792,6 @@ THREADED_TEST(AccessControlGetOwnPropertyNames) {
|
||||
}
|
||||
|
||||
|
||||
TEST(SuperAccessControl) {
|
||||
i::FLAG_allow_natives_syntax = true;
|
||||
v8::Isolate* isolate = CcTest::isolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
v8::Handle<v8::ObjectTemplate> obj_template =
|
||||
v8::ObjectTemplate::New(isolate);
|
||||
obj_template->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL);
|
||||
LocalContext env;
|
||||
env->Global()->Set(v8_str("prohibited"), obj_template->NewInstance());
|
||||
|
||||
{
|
||||
v8::TryCatch try_catch(isolate);
|
||||
CompileRun(
|
||||
"var f = { m() { return super.hasOwnProperty; } }.m;"
|
||||
"var m = %ToMethod(f, prohibited);"
|
||||
"m();");
|
||||
CHECK(try_catch.HasCaught());
|
||||
}
|
||||
|
||||
{
|
||||
v8::TryCatch try_catch(isolate);
|
||||
CompileRun(
|
||||
"var f = {m() { return super[42]; } }.m;"
|
||||
"var m = %ToMethod(f, prohibited);"
|
||||
"m();");
|
||||
CHECK(try_catch.HasCaught());
|
||||
}
|
||||
|
||||
{
|
||||
v8::TryCatch try_catch(isolate);
|
||||
CompileRun(
|
||||
"var f = {m() { super.hasOwnProperty = function () {}; } }.m;"
|
||||
"var m = %ToMethod(f, prohibited);"
|
||||
"m();");
|
||||
CHECK(try_catch.HasCaught());
|
||||
}
|
||||
|
||||
{
|
||||
v8::TryCatch try_catch(isolate);
|
||||
CompileRun(
|
||||
"Object.defineProperty(Object.prototype, 'x', { set : function(){}});"
|
||||
"var f = {"
|
||||
" m() { "
|
||||
" 'use strict';"
|
||||
" super.x = function () {};"
|
||||
" }"
|
||||
"}.m;"
|
||||
"var m = %ToMethod(f, prohibited);"
|
||||
"m();");
|
||||
CHECK(try_catch.HasCaught());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST(Regress470113) {
|
||||
v8::Isolate* isolate = CcTest::isolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
@ -1,106 +0,0 @@
|
||||
// Copyright 2014 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
// Flags: --allow-natives-syntax
|
||||
|
||||
|
||||
(function TestSingleClass() {
|
||||
function f(x) {
|
||||
var a = [0, 1, 2]
|
||||
return a[x];
|
||||
}
|
||||
|
||||
function ClassD() { }
|
||||
|
||||
assertEquals(1, f(1));
|
||||
var g = %ToMethod(f, ClassD.prototype);
|
||||
assertEquals(1, g(1));
|
||||
assertEquals(undefined, f[%HomeObjectSymbol()]);
|
||||
assertEquals(ClassD.prototype, g[%HomeObjectSymbol()]);
|
||||
}());
|
||||
|
||||
|
||||
(function TestClassHierarchy() {
|
||||
function f(x) {
|
||||
return function g(y) { x++; return x + y; };
|
||||
}
|
||||
|
||||
function Base() {}
|
||||
function Derived() { }
|
||||
Derived.prototype = Object.create(Base.prototype);
|
||||
|
||||
var q = f(0);
|
||||
assertEquals(2, q(1));
|
||||
assertEquals(3, q(1));
|
||||
var g = %ToMethod(q, Derived.prototype);
|
||||
assertFalse(g === q);
|
||||
assertEquals(4, g(1));
|
||||
assertEquals(5, q(1));
|
||||
}());
|
||||
|
||||
|
||||
(function TestPrototypeChain() {
|
||||
var o = {};
|
||||
var o1 = {};
|
||||
function f() { }
|
||||
|
||||
function g() { }
|
||||
|
||||
var fMeth = %ToMethod(f, o);
|
||||
assertEquals(o, fMeth[%HomeObjectSymbol()]);
|
||||
g.__proto__ = fMeth;
|
||||
assertEquals(undefined, g[%HomeObjectSymbol()]);
|
||||
var gMeth = %ToMethod(g, o1);
|
||||
assertEquals(fMeth, gMeth.__proto__);
|
||||
assertEquals(o, fMeth[%HomeObjectSymbol()]);
|
||||
assertEquals(o1, gMeth[%HomeObjectSymbol()]);
|
||||
}());
|
||||
|
||||
|
||||
(function TestBoundFunction() {
|
||||
var o = {};
|
||||
var p = {};
|
||||
|
||||
|
||||
function f(x, y, z, w) {
|
||||
assertEquals(o, this);
|
||||
assertEquals(1, x);
|
||||
assertEquals(2, y);
|
||||
assertEquals(3, z);
|
||||
assertEquals(4, w);
|
||||
return x+y+z+w;
|
||||
}
|
||||
|
||||
var fBound = f.bind(o, 1, 2, 3);
|
||||
var fMeth = %ToMethod(fBound, p);
|
||||
assertEquals(10, fMeth(4));
|
||||
assertEquals(10, fMeth.call(p, 4));
|
||||
var fBound1 = fBound.bind(o, 4);
|
||||
assertEquals(10, fBound1());
|
||||
var fMethBound = fMeth.bind(o, 4);
|
||||
assertEquals(10, fMethBound());
|
||||
}());
|
||||
|
||||
(function TestOptimized() {
|
||||
function f(o) {
|
||||
return o.x;
|
||||
}
|
||||
var o = {x : 15};
|
||||
assertEquals(15, f(o));
|
||||
assertEquals(15, f(o));
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
assertEquals(15, f(o));
|
||||
var g = %ToMethod(f, {});
|
||||
var o1 = {y : 1024, x : "abc"};
|
||||
assertEquals("abc", f(o1));
|
||||
assertEquals("abc", g(o1));
|
||||
} ());
|
||||
|
||||
(function TestExtensibility() {
|
||||
function f() {}
|
||||
Object.preventExtensions(f);
|
||||
assertFalse(Object.isExtensible(f));
|
||||
var m = %ToMethod(f, {});
|
||||
assertTrue(Object.isExtensible(m));
|
||||
}());
|
@ -81,39 +81,6 @@
|
||||
}());
|
||||
|
||||
|
||||
(function TestSuperNumericKeyedLoads() {
|
||||
var x = 1;
|
||||
var derivedDataProperty = 2;
|
||||
var f = 3;
|
||||
|
||||
function Base() { }
|
||||
function fBase() { return "Base " + this.toString(); }
|
||||
Base.prototype[f] = %ToMethod(fBase, Base.prototype);
|
||||
Base.prototype[x] = 15;
|
||||
Base.prototype.toString = function() { return "this is Base"; };
|
||||
|
||||
function Derived() {
|
||||
this[derivedDataProperty] = "xxx";
|
||||
}
|
||||
Derived.prototype = {
|
||||
__proto__: Base.prototype,
|
||||
toString() { return "this is Derived"; },
|
||||
1: 27,
|
||||
3() {
|
||||
assertEquals("Base this is Derived", super[f]());
|
||||
var a = super[x];
|
||||
assertEquals(15, a);
|
||||
assertEquals(15, super[x]);
|
||||
assertEquals(27, this[x]);
|
||||
return "Derived";
|
||||
}
|
||||
};
|
||||
|
||||
assertEquals("Base this is Base", new Base()[f]());
|
||||
assertEquals("Derived", new Derived()[f]());
|
||||
}());
|
||||
|
||||
|
||||
(function TestSuperKeywordNonMethod() {
|
||||
'use strict';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user