Commit 90291792 authored by gsathya's avatar gsathya Committed by Commit bot

[builtins] Add ReturnReceiver builtin

This removes RegExpPrototypeSpeciesGetter and IteratorPrototypeIterator and
uses ReturnReceiver builtin instead.

This patch also ports the PromiseSpecies to TF by reusing this
builtin.

BUG=v8:5343

Review-Url: https://codereview.chromium.org/2590373002
Cr-Commit-Position: refs/heads/master@{#41879}
parent b0c05f4a
......@@ -955,7 +955,6 @@ v8_source_set("v8_base") {
"src/builtins/builtins-handler.cc",
"src/builtins/builtins-internal.cc",
"src/builtins/builtins-interpreter.cc",
"src/builtins/builtins-iterator.cc",
"src/builtins/builtins-json.cc",
"src/builtins/builtins-math.cc",
"src/builtins/builtins-number.cc",
......
......@@ -702,7 +702,7 @@ void Genesis::CreateIteratorMaps(Handle<JSFunction> empty) {
Handle<JSFunction> iterator_prototype_iterator = SimpleCreateFunction(
isolate(), factory()->NewStringFromAsciiChecked("[Symbol.iterator]"),
Builtins::kIteratorPrototypeIterator, 0, true);
Builtins::kReturnReceiver, 0, true);
iterator_prototype_iterator->shared()->set_native(true);
JSObject::AddProperty(iterator_prototype, factory()->iterator_symbol(),
......@@ -1883,6 +1883,10 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
SimpleInstallFunction(prototype, "catch", Builtins::kIllegal, 1, true,
DONT_ENUM);
SimpleInstallGetter(promise_fun, factory->symbol_species_string(),
factory->species_symbol(), Builtins::kReturnReceiver,
true);
Handle<Map> prototype_map(prototype->map());
Map::SetShouldBeFastPrototypeMap(prototype_map, true, isolate);
......@@ -2070,10 +2074,9 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
{
// RegExp getters and setters.
SimpleInstallGetter(regexp_fun,
factory->InternalizeUtf8String("[Symbol.species]"),
factory->species_symbol(),
Builtins::kRegExpPrototypeSpeciesGetter, true);
SimpleInstallGetter(regexp_fun, factory->symbol_species_string(),
factory->species_symbol(), Builtins::kReturnReceiver,
true);
// Static properties set by a successful match.
......
......@@ -309,5 +309,10 @@ void Builtins::Generate_NewRestParameterElements(
assembler.Return(assembler.EmptyFixedArrayConstant());
}
void Builtins::Generate_ReturnReceiver(compiler::CodeAssemblerState* state) {
CodeStubAssembler assembler(state);
assembler.Return(assembler.Parameter(0));
}
} // namespace internal
} // namespace v8
// Copyright 2016 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.
#include "src/builtins/builtins-utils.h"
#include "src/builtins/builtins.h"
#include "src/code-stub-assembler.h"
#include "src/frames-inl.h"
namespace v8 {
namespace internal {
void Builtins::Generate_IteratorPrototypeIterator(
compiler::CodeAssemblerState* state) {
CodeStubAssembler assembler(state);
assembler.Return(assembler.Parameter(0));
}
} // namespace internal
} // namespace v8
......@@ -947,12 +947,6 @@ BUILTIN(RegExpPrototypeToString) {
RETURN_RESULT_OR_FAILURE(isolate, builder.Finish());
}
// ES6 21.2.4.2.
TF_BUILTIN(RegExpPrototypeSpeciesGetter, RegExpBuiltinsAssembler) {
Node* const receiver = Parameter(0);
Return(receiver);
}
// Fast-path implementation for flag checks on an unmodified JSRegExp instance.
Node* RegExpBuiltinsAssembler::FastFlagGetter(Node* const regexp,
JSRegExp::Flag flag) {
......
......@@ -211,6 +211,7 @@ namespace internal {
CPP(RestrictedFunctionPropertiesThrower) \
CPP(RestrictedStrictArgumentsPropertiesThrower) \
CPP(UnsupportedThrower) \
TFJ(ReturnReceiver, 0) \
\
/* Array */ \
ASM(ArrayCode) \
......@@ -404,9 +405,6 @@ namespace internal {
/* ES6 section 18.2.3 isNaN ( number ) */ \
TFJ(GlobalIsNaN, 1) \
\
/* ES6 #sec-%iteratorprototype%-@@iterator */ \
TFJ(IteratorPrototypeIterator, 0) \
\
/* JSON */ \
CPP(JsonParse) \
CPP(JsonStringify) \
......@@ -625,7 +623,6 @@ namespace internal {
TFJ(RegExpPrototypeReplace, 2) \
TFJ(RegExpPrototypeSearch, 1) \
TFJ(RegExpPrototypeSourceGetter, 0) \
TFJ(RegExpPrototypeSpeciesGetter, 0) \
TFJ(RegExpPrototypeSplit, 2) \
TFJ(RegExpPrototypeStickyGetter, 0) \
TFJ(RegExpPrototypeTest, 1) \
......
......@@ -152,6 +152,7 @@
V(String_string, "String") \
V(symbol_string, "symbol") \
V(Symbol_string, "Symbol") \
V(symbol_species_string, "[Symbol.species]") \
V(SyntaxError_string, "SyntaxError") \
V(then_string, "then") \
V(this_string, "this") \
......
......@@ -23,8 +23,6 @@ var promiseHandledHintSymbol =
var promiseRawSymbol = utils.ImportNow("promise_raw_symbol");
var promiseStateSymbol = utils.ImportNow("promise_state_symbol");
var promiseResultSymbol = utils.ImportNow("promise_result_symbol");
var SpeciesConstructor;
var speciesSymbol = utils.ImportNow("species_symbol");
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
var ObjectHasOwnProperty;
var GlobalPromise = global.Promise;
......@@ -32,7 +30,6 @@ var PromiseThen = GlobalPromise.prototype.then;
utils.Import(function(from) {
ObjectHasOwnProperty = from.ObjectHasOwnProperty;
SpeciesConstructor = from.SpeciesConstructor;
});
// -------------------------------------------------------------------
......@@ -343,11 +340,6 @@ function MarkPromiseAsHandled(promise) {
%PromiseMarkAsHandled(promise);
}
function PromiseSpecies() {
return this;
}
// -------------------------------------------------------------------
// Install exported functions.
......@@ -358,8 +350,6 @@ utils.InstallFunctions(GlobalPromise, DONT_ENUM, [
"resolve", PromiseResolve
]);
utils.InstallGetter(GlobalPromise, speciesSymbol, PromiseSpecies);
%SetCode(GlobalPromise.prototype.catch, PromiseCatch);
%InstallToContext([
......
......@@ -494,7 +494,6 @@
'builtins/builtins-handler.cc',
'builtins/builtins-internal.cc',
'builtins/builtins-interpreter.cc',
'builtins/builtins-iterator.cc',
'builtins/builtins-json.cc',
'builtins/builtins-math.cc',
'builtins/builtins-number.cc',
......
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