Skip to content

Commit ff2c9ea

Browse files
bmeurerCommit bot
authored andcommitted
[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 68e4897. R=jarin@chromium.org BUG=v8:3330 LOG=n Review URL: https://codereview.chromium.org/1366063002 Cr-Commit-Position: refs/heads/master@{#30925}
1 parent bd35b54 commit ff2c9ea

7 files changed

Lines changed: 0 additions & 236 deletions

File tree

src/objects.cc

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10134,30 +10134,6 @@ void JSFunction::AttemptConcurrentOptimization() {
1013410134
}
1013510135

1013610136

10137-
Handle<JSFunction> JSFunction::CloneClosure(Handle<JSFunction> function) {
10138-
Isolate* isolate = function->GetIsolate();
10139-
Handle<Map> map(function->map());
10140-
Handle<SharedFunctionInfo> shared(function->shared());
10141-
Handle<Context> context(function->context());
10142-
Handle<JSFunction> clone =
10143-
isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context);
10144-
10145-
if (shared->bound()) {
10146-
clone->set_function_bindings(function->function_bindings());
10147-
}
10148-
10149-
// In typical case, __proto__ of ``function`` is the default Function
10150-
// prototype, which means that SetPrototype below is a no-op.
10151-
// In rare cases when that is not true, we mutate the clone's __proto__.
10152-
Handle<Object> original_prototype(map->prototype(), isolate);
10153-
if (*original_prototype != clone->map()->prototype()) {
10154-
JSObject::SetPrototype(clone, original_prototype, false).Assert();
10155-
}
10156-
10157-
return clone;
10158-
}
10159-
10160-
1016110137
void SharedFunctionInfo::AddSharedCodeToOptimizedCodeMap(
1016210138
Handle<SharedFunctionInfo> shared, Handle<Code> code) {
1016310139
Isolate* isolate = shared->GetIsolate();

src/objects.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7141,11 +7141,6 @@ class JSFunction: public JSObject {
71417141
static void SetInstancePrototype(Handle<JSFunction> function,
71427142
Handle<Object> value);
71437143

7144-
// Creates a new closure for the fucntion with the same bindings,
7145-
// bound values, and prototype. An equivalent of spec operations
7146-
// ``CloneMethod`` and ``CloneBoundFunction``.
7147-
static Handle<JSFunction> CloneClosure(Handle<JSFunction> function);
7148-
71497144
// After prototype is removed, it will not be created when accessed, and
71507145
// [[Construct]] from this function will not be allowed.
71517146
bool RemovePrototype();

src/runtime/runtime-classes.cc

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,6 @@ RUNTIME_FUNCTION(Runtime_ThrowIfStaticPrototype) {
7474
}
7575

7676

77-
RUNTIME_FUNCTION(Runtime_ToMethod) {
78-
HandleScope scope(isolate);
79-
DCHECK(args.length() == 2);
80-
CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
81-
CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
82-
Handle<JSFunction> clone = JSFunction::CloneClosure(fun);
83-
Handle<Symbol> home_object_symbol(isolate->factory()->home_object_symbol());
84-
JSObject::SetOwnPropertyIgnoreAttributes(clone, home_object_symbol,
85-
home_object, DONT_ENUM).Assert();
86-
return *clone;
87-
}
88-
89-
9077
RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) {
9178
DCHECK(args.length() == 0);
9279
return isolate->heap()->home_object_symbol();

src/runtime/runtime.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ namespace internal {
8080
F(ThrowArrayNotSubclassableError, 0, 1) \
8181
F(ThrowStaticPrototypeError, 0, 1) \
8282
F(ThrowIfStaticPrototype, 1, 1) \
83-
F(ToMethod, 2, 1) \
8483
F(HomeObjectSymbol, 0, 1) \
8584
F(DefineClass, 5, 1) \
8685
F(FinalizeClassDefinition, 2, 1) \

test/cctest/test-api.cc

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8792,60 +8792,6 @@ THREADED_TEST(AccessControlGetOwnPropertyNames) {
87928792
}
87938793

87948794

8795-
TEST(SuperAccessControl) {
8796-
i::FLAG_allow_natives_syntax = true;
8797-
v8::Isolate* isolate = CcTest::isolate();
8798-
v8::HandleScope handle_scope(isolate);
8799-
v8::Handle<v8::ObjectTemplate> obj_template =
8800-
v8::ObjectTemplate::New(isolate);
8801-
obj_template->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL);
8802-
LocalContext env;
8803-
env->Global()->Set(v8_str("prohibited"), obj_template->NewInstance());
8804-
8805-
{
8806-
v8::TryCatch try_catch(isolate);
8807-
CompileRun(
8808-
"var f = { m() { return super.hasOwnProperty; } }.m;"
8809-
"var m = %ToMethod(f, prohibited);"
8810-
"m();");
8811-
CHECK(try_catch.HasCaught());
8812-
}
8813-
8814-
{
8815-
v8::TryCatch try_catch(isolate);
8816-
CompileRun(
8817-
"var f = {m() { return super[42]; } }.m;"
8818-
"var m = %ToMethod(f, prohibited);"
8819-
"m();");
8820-
CHECK(try_catch.HasCaught());
8821-
}
8822-
8823-
{
8824-
v8::TryCatch try_catch(isolate);
8825-
CompileRun(
8826-
"var f = {m() { super.hasOwnProperty = function () {}; } }.m;"
8827-
"var m = %ToMethod(f, prohibited);"
8828-
"m();");
8829-
CHECK(try_catch.HasCaught());
8830-
}
8831-
8832-
{
8833-
v8::TryCatch try_catch(isolate);
8834-
CompileRun(
8835-
"Object.defineProperty(Object.prototype, 'x', { set : function(){}});"
8836-
"var f = {"
8837-
" m() { "
8838-
" 'use strict';"
8839-
" super.x = function () {};"
8840-
" }"
8841-
"}.m;"
8842-
"var m = %ToMethod(f, prohibited);"
8843-
"m();");
8844-
CHECK(try_catch.HasCaught());
8845-
}
8846-
}
8847-
8848-
88498795
TEST(Regress470113) {
88508796
v8::Isolate* isolate = CcTest::isolate();
88518797
v8::HandleScope handle_scope(isolate);

test/mjsunit/es6/toMethod.js

Lines changed: 0 additions & 106 deletions
This file was deleted.

test/mjsunit/harmony/super.js

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -81,39 +81,6 @@
8181
}());
8282

8383

84-
(function TestSuperNumericKeyedLoads() {
85-
var x = 1;
86-
var derivedDataProperty = 2;
87-
var f = 3;
88-
89-
function Base() { }
90-
function fBase() { return "Base " + this.toString(); }
91-
Base.prototype[f] = %ToMethod(fBase, Base.prototype);
92-
Base.prototype[x] = 15;
93-
Base.prototype.toString = function() { return "this is Base"; };
94-
95-
function Derived() {
96-
this[derivedDataProperty] = "xxx";
97-
}
98-
Derived.prototype = {
99-
__proto__: Base.prototype,
100-
toString() { return "this is Derived"; },
101-
1: 27,
102-
3() {
103-
assertEquals("Base this is Derived", super[f]());
104-
var a = super[x];
105-
assertEquals(15, a);
106-
assertEquals(15, super[x]);
107-
assertEquals(27, this[x]);
108-
return "Derived";
109-
}
110-
};
111-
112-
assertEquals("Base this is Base", new Base()[f]());
113-
assertEquals("Derived", new Derived()[f]());
114-
}());
115-
116-
11784
(function TestSuperKeywordNonMethod() {
11885
'use strict';
11986

0 commit comments

Comments
 (0)