Commit 3d3dafee authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[builtins] Define interface descriptors for builtins with JSFunction linkage.

Second bulk of changes.

BUG=v8:6116

Change-Id: I6297c4e3e1c0230a96dc6197691a54c07cc61c88
Reviewed-on: https://chromium-review.googlesource.com/457320
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43995}
parent 9dfa4639
This diff is collapsed.
......@@ -257,9 +257,9 @@ Node* AsyncFromSyncBuiltinsAssembler::AllocateAsyncIteratorValueUnwrapContext(
// https://tc39.github.io/proposal-async-iteration/
// Section #sec-%asyncfromsynciteratorprototype%.next
TF_BUILTIN(AsyncFromSyncIteratorPrototypeNext, AsyncFromSyncBuiltinsAssembler) {
Node* const iterator = Parameter(0);
Node* const value = Parameter(1);
Node* const context = Parameter(4);
Node* const iterator = Parameter(Descriptor::kReceiver);
Node* const value = Parameter(Descriptor::kValue);
Node* const context = Parameter(Descriptor::kContext);
Generate_AsyncFromSyncIteratorMethod(
context, iterator, value, factory()->next_string(),
......@@ -270,9 +270,9 @@ TF_BUILTIN(AsyncFromSyncIteratorPrototypeNext, AsyncFromSyncBuiltinsAssembler) {
// Section #sec-%asyncfromsynciteratorprototype%.return
TF_BUILTIN(AsyncFromSyncIteratorPrototypeReturn,
AsyncFromSyncBuiltinsAssembler) {
Node* const iterator = Parameter(0);
Node* const value = Parameter(1);
Node* const context = Parameter(4);
Node* const iterator = Parameter(Descriptor::kReceiver);
Node* const value = Parameter(Descriptor::kValue);
Node* const context = Parameter(Descriptor::kContext);
auto if_return_undefined = [=](Node* const native_context,
Node* const promise, Label* if_exception) {
......@@ -298,9 +298,9 @@ TF_BUILTIN(AsyncFromSyncIteratorPrototypeReturn,
// Section #sec-%asyncfromsynciteratorprototype%.throw
TF_BUILTIN(AsyncFromSyncIteratorPrototypeThrow,
AsyncFromSyncBuiltinsAssembler) {
Node* const iterator = Parameter(0);
Node* const reason = Parameter(1);
Node* const context = Parameter(4);
Node* const iterator = Parameter(Descriptor::kReceiver);
Node* const reason = Parameter(Descriptor::kReason);
Node* const context = Parameter(Descriptor::kContext);
auto if_throw_undefined = [=](Node* const native_context, Node* const promise,
Label* if_exception) { Goto(if_exception); };
......@@ -312,8 +312,8 @@ TF_BUILTIN(AsyncFromSyncIteratorPrototypeThrow,
}
TF_BUILTIN(AsyncIteratorValueUnwrap, AsyncFromSyncBuiltinsAssembler) {
Node* const value = Parameter(1);
Node* const context = Parameter(4);
Node* const value = Parameter(Descriptor::kValue);
Node* const context = Parameter(Descriptor::kContext);
Node* const done = LoadContextElement(context, ValueUnwrapContext::kDoneSlot);
CSA_ASSERT(this, IsBoolean(done));
......
......@@ -92,7 +92,7 @@ TF_BUILTIN(ObjectHasOwnProperty, ObjectBuiltinsAssembler) {
Return(CallRuntime(Runtime::kObjectHasOwnProperty, context, object, key));
}
// ES6 section 19.1.3.6 Object.prototype.toString
// ES6 #sec-object.prototype.tostring
TF_BUILTIN(ObjectProtoToString, ObjectBuiltinsAssembler) {
Label return_undefined(this, Label::kDeferred),
return_null(this, Label::kDeferred),
......@@ -107,8 +107,8 @@ TF_BUILTIN(ObjectProtoToString, ObjectBuiltinsAssembler) {
Label checkstringtag(this);
Label if_tostringtag(this), if_notostringtag(this);
Node* receiver = Parameter(0);
Node* context = Parameter(3);
Node* receiver = Parameter(Descriptor::kReceiver);
Node* context = Parameter(Descriptor::kContext);
GotoIf(WordEqual(receiver, UndefinedConstant()), &return_undefined);
......@@ -255,10 +255,10 @@ TF_BUILTIN(ObjectProtoToString, ObjectBuiltinsAssembler) {
}
}
// ES6 19.3.7 Object.prototype.valueOf
// ES6 #sec-object.prototype.valueof
TF_BUILTIN(ObjectPrototypeValueOf, CodeStubAssembler) {
Node* receiver = Parameter(0);
Node* context = Parameter(3);
Node* receiver = Parameter(Descriptor::kReceiver);
Node* context = Parameter(Descriptor::kContext);
Callable to_object = CodeFactory::ToObject(isolate());
receiver = CallStub(to_object, context, receiver);
......@@ -266,10 +266,11 @@ TF_BUILTIN(ObjectPrototypeValueOf, CodeStubAssembler) {
Return(receiver);
}
// ES #sec-object.create
TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) {
Node* prototype = Parameter(1);
Node* properties = Parameter(2);
Node* context = Parameter(3 + 2);
Node* prototype = Parameter(Descriptor::kPrototype);
Node* properties = Parameter(Descriptor::kProperties);
Node* context = Parameter(Descriptor::kContext);
Label call_runtime(this, Label::kDeferred), prototype_valid(this),
no_properties(this);
......
......@@ -975,8 +975,8 @@ void PromiseBuiltinsAssembler::InternalPromiseReject(Node* context,
// ES#sec-promise-reject-functions
// Promise Reject Functions
TF_BUILTIN(PromiseRejectClosure, PromiseBuiltinsAssembler) {
Node* const value = Parameter(1);
Node* const context = Parameter(4);
Node* const value = Parameter(Descriptor::kValue);
Node* const context = Parameter(Descriptor::kContext);
Label out(this);
......@@ -1006,10 +1006,11 @@ TF_BUILTIN(PromiseRejectClosure, PromiseBuiltinsAssembler) {
Return(UndefinedConstant());
}
// ES6 #sec-promise-executor
TF_BUILTIN(PromiseConstructor, PromiseBuiltinsAssembler) {
Node* const executor = Parameter(1);
Node* const new_target = Parameter(2);
Node* const context = Parameter(4);
Node* const executor = Parameter(Descriptor::kExecutor);
Node* const new_target = Parameter(Descriptor::kNewTarget);
Node* const context = Parameter(Descriptor::kContext);
Isolate* isolate = this->isolate();
Label if_targetisundefined(this, Label::kDeferred);
......@@ -1129,13 +1130,13 @@ TF_BUILTIN(PromiseConstructor, PromiseBuiltinsAssembler) {
}
TF_BUILTIN(PromiseInternalConstructor, PromiseBuiltinsAssembler) {
Node* const parent = Parameter(1);
Node* const context = Parameter(4);
Node* const parent = Parameter(Descriptor::kParent);
Node* const context = Parameter(Descriptor::kContext);
Return(AllocateAndInitJSPromise(context, parent));
}
TF_BUILTIN(IsPromise, PromiseBuiltinsAssembler) {
Node* const maybe_promise = Parameter(1);
Node* const maybe_promise = Parameter(Descriptor::kObject);
Label if_notpromise(this, Label::kDeferred);
GotoIf(TaggedIsSmi(maybe_promise), &if_notpromise);
......@@ -1152,10 +1153,10 @@ TF_BUILTIN(IsPromise, PromiseBuiltinsAssembler) {
// Promise.prototype.catch ( onFulfilled, onRejected )
TF_BUILTIN(PromiseThen, PromiseBuiltinsAssembler) {
// 1. Let promise be the this value.
Node* const promise = Parameter(0);
Node* const on_resolve = Parameter(1);
Node* const on_reject = Parameter(2);
Node* const context = Parameter(5);
Node* const promise = Parameter(Descriptor::kReceiver);
Node* const on_resolve = Parameter(Descriptor::kOnFullfilled);
Node* const on_reject = Parameter(Descriptor::kOnRejected);
Node* const context = Parameter(Descriptor::kContext);
Node* const result =
InternalPromiseThen(context, promise, on_resolve, on_reject);
......@@ -1165,8 +1166,8 @@ TF_BUILTIN(PromiseThen, PromiseBuiltinsAssembler) {
// ES#sec-promise-resolve-functions
// Promise Resolve Functions
TF_BUILTIN(PromiseResolveClosure, PromiseBuiltinsAssembler) {
Node* const value = Parameter(1);
Node* const context = Parameter(4);
Node* const value = Parameter(Descriptor::kValue);
Node* const context = Parameter(Descriptor::kContext);
Label out(this);
......@@ -1194,10 +1195,11 @@ TF_BUILTIN(PromiseResolveClosure, PromiseBuiltinsAssembler) {
Return(UndefinedConstant());
}
// ES #sec-fulfillpromise
TF_BUILTIN(ResolvePromise, PromiseBuiltinsAssembler) {
Node* const promise = Parameter(1);
Node* const result = Parameter(2);
Node* const context = Parameter(5);
Node* const promise = Parameter(Descriptor::kPromise);
Node* const result = Parameter(Descriptor::kValue);
Node* const context = Parameter(Descriptor::kContext);
InternalResolvePromise(context, promise, result);
Return(UndefinedConstant());
......@@ -1231,12 +1233,12 @@ TF_BUILTIN(PromiseHandleReject, PromiseBuiltinsAssembler) {
}
TF_BUILTIN(PromiseHandle, PromiseBuiltinsAssembler) {
Node* const value = Parameter(1);
Node* const handler = Parameter(2);
Node* const deferred_promise = Parameter(3);
Node* const deferred_on_resolve = Parameter(4);
Node* const deferred_on_reject = Parameter(5);
Node* const context = Parameter(8);
Node* const value = Parameter(Descriptor::kValue);
Node* const handler = Parameter(Descriptor::kHandler);
Node* const deferred_promise = Parameter(Descriptor::kDeferredPromise);
Node* const deferred_on_resolve = Parameter(Descriptor::kDeferredOnResolve);
Node* const deferred_on_reject = Parameter(Descriptor::kDeferredOnReject);
Node* const context = Parameter(Descriptor::kContext);
Isolate* isolate = this->isolate();
Variable var_reason(this, MachineRepresentation::kTagged);
......@@ -1344,10 +1346,10 @@ TF_BUILTIN(PromiseHandle, PromiseBuiltinsAssembler) {
// Promise.prototype.catch ( onRejected )
TF_BUILTIN(PromiseCatch, PromiseBuiltinsAssembler) {
// 1. Let promise be the this value.
Node* const promise = Parameter(0);
Node* const promise = Parameter(Descriptor::kReceiver);
Node* const on_resolve = UndefinedConstant();
Node* const on_reject = Parameter(1);
Node* const context = Parameter(4);
Node* const on_reject = Parameter(Descriptor::kOnRejected);
Node* const context = Parameter(Descriptor::kContext);
Label if_internalthen(this), if_customthen(this, Label::kDeferred);
GotoIf(TaggedIsSmi(promise), &if_customthen);
......@@ -1373,9 +1375,9 @@ TF_BUILTIN(PromiseCatch, PromiseBuiltinsAssembler) {
TF_BUILTIN(PromiseResolve, PromiseBuiltinsAssembler) {
// 1. Let C be the this value.
Node* receiver = Parameter(0);
Node* value = Parameter(1);
Node* context = Parameter(4);
Node* receiver = Parameter(Descriptor::kReceiver);
Node* value = Parameter(Descriptor::kValue);
Node* context = Parameter(Descriptor::kContext);
Isolate* isolate = this->isolate();
// 2. If Type(C) is not Object, throw a TypeError exception.
......@@ -1455,10 +1457,11 @@ TF_BUILTIN(PromiseResolve, PromiseBuiltinsAssembler) {
}
}
// ES6 #sec-getcapabilitiesexecutor-functions
TF_BUILTIN(PromiseGetCapabilitiesExecutor, PromiseBuiltinsAssembler) {
Node* const resolve = Parameter(1);
Node* const reject = Parameter(2);
Node* const context = Parameter(5);
Node* const resolve = Parameter(Descriptor::kResolve);
Node* const reject = Parameter(Descriptor::kReject);
Node* const context = Parameter(Descriptor::kContext);
Node* const capability = LoadContextElement(context, kCapabilitySlot);
......@@ -1483,10 +1486,11 @@ TF_BUILTIN(PromiseGetCapabilitiesExecutor, PromiseBuiltinsAssembler) {
Unreachable();
}
// ES6 #sec-newpromisecapability
TF_BUILTIN(NewPromiseCapability, PromiseBuiltinsAssembler) {
Node* constructor = Parameter(1);
Node* debug_event = Parameter(2);
Node* context = Parameter(5);
Node* constructor = Parameter(Descriptor::kConstructor);
Node* debug_event = Parameter(Descriptor::kDebugEvent);
Node* context = Parameter(Descriptor::kContext);
CSA_ASSERT_JS_ARGC_EQ(this, 2);
......@@ -1495,9 +1499,9 @@ TF_BUILTIN(NewPromiseCapability, PromiseBuiltinsAssembler) {
TF_BUILTIN(PromiseReject, PromiseBuiltinsAssembler) {
// 1. Let C be the this value.
Node* const receiver = Parameter(0);
Node* const reason = Parameter(1);
Node* const context = Parameter(4);
Node* const receiver = Parameter(Descriptor::kReceiver);
Node* const reason = Parameter(Descriptor::kReason);
Node* const context = Parameter(Descriptor::kContext);
// 2. If Type(C) is not Object, throw a TypeError exception.
ThrowIfNotJSReceiver(context, receiver, MessageTemplate::kCalledOnNonObject,
......@@ -1538,10 +1542,10 @@ TF_BUILTIN(PromiseReject, PromiseBuiltinsAssembler) {
}
TF_BUILTIN(InternalPromiseReject, PromiseBuiltinsAssembler) {
Node* const promise = Parameter(1);
Node* const reason = Parameter(2);
Node* const debug_event = Parameter(3);
Node* const context = Parameter(6);
Node* const promise = Parameter(Descriptor::kPromise);
Node* const reason = Parameter(Descriptor::kReason);
Node* const debug_event = Parameter(Descriptor::kDebugEvent);
Node* const context = Parameter(Descriptor::kContext);
InternalPromiseReject(context, promise, reason, debug_event);
Return(UndefinedConstant());
......@@ -1573,7 +1577,7 @@ std::pair<Node*, Node*> PromiseBuiltinsAssembler::CreatePromiseFinallyFunctions(
}
TF_BUILTIN(PromiseValueThunkFinally, PromiseBuiltinsAssembler) {
Node* const context = Parameter(3);
Node* const context = Parameter(Descriptor::kContext);
Node* const value = LoadContextElement(context, kOnFinallySlot);
Return(value);
......@@ -1603,8 +1607,8 @@ Node* PromiseBuiltinsAssembler::CreateValueThunkFunction(Node* value,
TF_BUILTIN(PromiseThenFinally, PromiseBuiltinsAssembler) {
CSA_ASSERT_JS_ARGC_EQ(this, 1);
Node* const value = Parameter(1);
Node* const context = Parameter(4);
Node* const value = Parameter(Descriptor::kValue);
Node* const context = Parameter(Descriptor::kContext);
Node* const on_finally = LoadContextElement(context, kOnFinallySlot);
......@@ -1633,7 +1637,7 @@ TF_BUILTIN(PromiseThenFinally, PromiseBuiltinsAssembler) {
}
TF_BUILTIN(PromiseThrowerFinally, PromiseBuiltinsAssembler) {
Node* const context = Parameter(3);
Node* const context = Parameter(Descriptor::kContext);
Node* const reason = LoadContextElement(context, kOnFinallySlot);
CallRuntime(Runtime::kThrow, context, reason);
......@@ -1664,8 +1668,8 @@ Node* PromiseBuiltinsAssembler::CreateThrowerFunction(Node* reason,
TF_BUILTIN(PromiseCatchFinally, PromiseBuiltinsAssembler) {
CSA_ASSERT_JS_ARGC_EQ(this, 1);
Node* const reason = Parameter(1);
Node* const context = Parameter(4);
Node* const reason = Parameter(Descriptor::kReason);
Node* const context = Parameter(Descriptor::kContext);
Node* const on_finally = LoadContextElement(context, kOnFinallySlot);
......@@ -1697,9 +1701,9 @@ TF_BUILTIN(PromiseFinally, PromiseBuiltinsAssembler) {
CSA_ASSERT_JS_ARGC_EQ(this, 1);
// 1. Let promise be the this value.
Node* const promise = Parameter(0);
Node* const on_finally = Parameter(1);
Node* const context = Parameter(4);
Node* const promise = Parameter(Descriptor::kReceiver);
Node* const on_finally = Parameter(Descriptor::kOnFinally);
Node* const context = Parameter(Descriptor::kContext);
// 2. If IsPromise(promise) is false, throw a TypeError exception.
ThrowIfNotInstanceType(context, promise, JS_PROMISE_TYPE,
......
This diff is collapsed.
......@@ -71,7 +71,8 @@ class RegExpBuiltinsAssembler : public CodeStubAssembler {
JSRegExp::Flag flag);
Node* FlagGetter(Node* const context, Node* const regexp, JSRegExp::Flag flag,
bool is_fastpath);
void FlagGetter(JSRegExp::Flag flag, v8::Isolate::UseCounterFeature counter,
void FlagGetter(Node* context, Node* receiver, JSRegExp::Flag flag,
v8::Isolate::UseCounterFeature counter,
const char* method_name);
Node* IsRegExp(Node* const context, Node* const maybe_receiver);
......
......@@ -140,9 +140,9 @@ void SharedArrayBufferBuiltinsAssembler::ValidateAtomicIndex(
}
TF_BUILTIN(AtomicsLoad, SharedArrayBufferBuiltinsAssembler) {
Node* array = Parameter(1);
Node* index = Parameter(2);
Node* context = Parameter(3 + 2);
Node* array = Parameter(Descriptor::kArray);
Node* index = Parameter(Descriptor::kIndex);
Node* context = Parameter(Descriptor::kContext);
Node* instance_type;
Node* backing_store;
......@@ -198,10 +198,10 @@ TF_BUILTIN(AtomicsLoad, SharedArrayBufferBuiltinsAssembler) {
}
TF_BUILTIN(AtomicsStore, SharedArrayBufferBuiltinsAssembler) {
Node* array = Parameter(1);
Node* index = Parameter(2);
Node* value = Parameter(3);
Node* context = Parameter(4 + 2);
Node* array = Parameter(Descriptor::kArray);
Node* index = Parameter(Descriptor::kIndex);
Node* value = Parameter(Descriptor::kValue);
Node* context = Parameter(Descriptor::kContext);
Node* instance_type;
Node* backing_store;
......@@ -250,10 +250,10 @@ TF_BUILTIN(AtomicsStore, SharedArrayBufferBuiltinsAssembler) {
}
TF_BUILTIN(AtomicsExchange, SharedArrayBufferBuiltinsAssembler) {
Node* array = Parameter(1);
Node* index = Parameter(2);
Node* value = Parameter(3);
Node* context = Parameter(4 + 2);
Node* array = Parameter(Descriptor::kArray);
Node* index = Parameter(Descriptor::kIndex);
Node* value = Parameter(Descriptor::kValue);
Node* context = Parameter(Descriptor::kContext);
Node* instance_type;
Node* backing_store;
......@@ -323,11 +323,11 @@ TF_BUILTIN(AtomicsExchange, SharedArrayBufferBuiltinsAssembler) {
}
TF_BUILTIN(AtomicsCompareExchange, SharedArrayBufferBuiltinsAssembler) {
Node* array = Parameter(1);
Node* index = Parameter(2);
Node* old_value = Parameter(3);
Node* new_value = Parameter(4);
Node* context = Parameter(5 + 2);
Node* array = Parameter(Descriptor::kArray);
Node* index = Parameter(Descriptor::kIndex);
Node* old_value = Parameter(Descriptor::kOldValue);
Node* new_value = Parameter(Descriptor::kNewValue);
Node* context = Parameter(Descriptor::kContext);
Node* instance_type;
Node* backing_store;
......
......@@ -475,7 +475,7 @@ TF_BUILTIN(StringCharCodeAt, CodeStubAssembler) {
// -----------------------------------------------------------------------------
// ES6 section 21.1 String Objects
// ES6 section 21.1.2.1 String.fromCharCode ( ...codeUnits )
// ES6 #sec-string.fromcharcode
TF_BUILTIN(StringFromCharCode, CodeStubAssembler) {
// TODO(ishell): use constants from Descriptor once the JSFunction linkage
// arguments are reordered.
......@@ -586,11 +586,11 @@ TF_BUILTIN(StringFromCharCode, CodeStubAssembler) {
}
}
// ES6 section 21.1.3.1 String.prototype.charAt ( pos )
// ES6 #sec-string.prototype.charat
TF_BUILTIN(StringPrototypeCharAt, CodeStubAssembler) {
Node* receiver = Parameter(0);
Node* position = Parameter(1);
Node* context = Parameter(4);
Node* receiver = Parameter(Descriptor::kReceiver);
Node* position = Parameter(Descriptor::kPosition);
Node* context = Parameter(Descriptor::kContext);
// Check that {receiver} is coercible to Object and convert it to a String.
receiver = ToThisString(context, receiver, "String.prototype.charAt");
......@@ -625,11 +625,11 @@ TF_BUILTIN(StringPrototypeCharAt, CodeStubAssembler) {
Return(result);
}
// ES6 section 21.1.3.2 String.prototype.charCodeAt ( pos )
// ES6 #sec-string.prototype.charcodeat
TF_BUILTIN(StringPrototypeCharCodeAt, CodeStubAssembler) {
Node* receiver = Parameter(0);
Node* position = Parameter(1);
Node* context = Parameter(4);
Node* receiver = Parameter(Descriptor::kReceiver);
Node* position = Parameter(Descriptor::kPosition);
Node* context = Parameter(Descriptor::kContext);
// Check that {receiver} is coercible to Object and convert it to a String.
receiver = ToThisString(context, receiver, "String.prototype.charCodeAt");
......@@ -663,8 +663,10 @@ TF_BUILTIN(StringPrototypeCharCodeAt, CodeStubAssembler) {
}
// ES6 String.prototype.concat(...args)
// #sec-string.prototype.concat
// ES6 #sec-string.prototype.concat
TF_BUILTIN(StringPrototypeConcat, CodeStubAssembler) {
// TODO(ishell): use constants from Descriptor once the JSFunction linkage
// arguments are reordered.
CodeStubArguments arguments(
this, ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount)));
Node* receiver = arguments.GetReceiver();
......@@ -975,14 +977,14 @@ void StringBuiltinsAssembler::MaybeCallFunctionAtSymbol(
Bind(&out);
}
// ES6 section 21.1.3.16 String.prototype.replace ( search, replace )
// ES6 #sec-string.prototype.replace
TF_BUILTIN(StringPrototypeReplace, StringBuiltinsAssembler) {
Label out(this);
Node* const receiver = Parameter(0);
Node* const search = Parameter(1);
Node* const replace = Parameter(2);
Node* const context = Parameter(5);
Node* const receiver = Parameter(Descriptor::kReceiver);
Node* const search = Parameter(Descriptor::kSearch);
Node* const replace = Parameter(Descriptor::kReplace);
Node* const context = Parameter(Descriptor::kContext);
Node* const smi_zero = SmiConstant(0);
......@@ -1147,10 +1149,10 @@ TF_BUILTIN(StringPrototypeReplace, StringBuiltinsAssembler) {
TF_BUILTIN(StringPrototypeSplit, StringBuiltinsAssembler) {
Label out(this);
Node* const receiver = Parameter(0);
Node* const separator = Parameter(1);
Node* const limit = Parameter(2);
Node* const context = Parameter(5);
Node* const receiver = Parameter(Descriptor::kReceiver);
Node* const separator = Parameter(Descriptor::kSeparator);
Node* const limit = Parameter(Descriptor::kLimit);
Node* const context = Parameter(Descriptor::kContext);
Node* const smi_zero = SmiConstant(0);
......@@ -1246,17 +1248,17 @@ TF_BUILTIN(StringPrototypeSplit, StringBuiltinsAssembler) {
Return(result);
}
// ES6 section B.2.3.1 String.prototype.substr ( start, length )
// ES6 #sec-string.prototype.substr
TF_BUILTIN(StringPrototypeSubstr, CodeStubAssembler) {
Label out(this), handle_length(this);
Variable var_start(this, MachineRepresentation::kTagged);
Variable var_length(this, MachineRepresentation::kTagged);
Node* const receiver = Parameter(0);
Node* const start = Parameter(1);
Node* const length = Parameter(2);
Node* const context = Parameter(5);
Node* const receiver = Parameter(Descriptor::kReceiver);
Node* const start = Parameter(Descriptor::kStart);
Node* const length = Parameter(Descriptor::kLength);
Node* const context = Parameter(Descriptor::kContext);
Node* const zero = SmiConstant(Smi::kZero);
......@@ -1415,17 +1417,17 @@ compiler::Node* StringBuiltinsAssembler::ToSmiBetweenZeroAnd(Node* context,
return var_result.value();
}
// ES6 section 21.1.3.19 String.prototype.substring ( start, end )
// ES6 #sec-string.prototype.substring
TF_BUILTIN(StringPrototypeSubstring, StringBuiltinsAssembler) {
Label out(this);
Variable var_start(this, MachineRepresentation::kTagged);
Variable var_end(this, MachineRepresentation::kTagged);
Node* const receiver = Parameter(0);
Node* const start = Parameter(1);
Node* const end = Parameter(2);
Node* const context = Parameter(5);
Node* const receiver = Parameter(Descriptor::kReceiver);
Node* const start = Parameter(Descriptor::kStart);
Node* const end = Parameter(Descriptor::kEnd);
Node* const context = Parameter(Descriptor::kContext);
// Check that {receiver} is coercible to Object and convert it to a String.
Node* const string =
......@@ -1464,20 +1466,20 @@ TF_BUILTIN(StringPrototypeSubstring, StringBuiltinsAssembler) {
}
}
// ES6 section 21.1.3.25 String.prototype.toString ()
// ES6 #sec-string.prototype.tostring
TF_BUILTIN(StringPrototypeToString, CodeStubAssembler) {
Node* receiver = Parameter(0);
Node* context = Parameter(3);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Node* result = ToThisValue(context, receiver, PrimitiveType::kString,
"String.prototype.toString");
Return(result);
}
// ES6 section 21.1.3.28 String.prototype.valueOf ( )
// ES6 #sec-string.prototype.valueof
TF_BUILTIN(StringPrototypeValueOf, CodeStubAssembler) {
Node* receiver = Parameter(0);
Node* context = Parameter(3);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Node* result = ToThisValue(context, receiver, PrimitiveType::kString,
"String.prototype.valueOf");
......@@ -1485,8 +1487,8 @@ TF_BUILTIN(StringPrototypeValueOf, CodeStubAssembler) {
}
TF_BUILTIN(StringPrototypeIterator, CodeStubAssembler) {
Node* receiver = Parameter(0);
Node* context = Parameter(3);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Node* string =
ToThisString(context, receiver, "String.prototype[Symbol.iterator]");
......@@ -1573,6 +1575,7 @@ compiler::Node* StringBuiltinsAssembler::LoadSurrogatePairAt(
return var_result.value();
}
// ES6 #sec-%stringiteratorprototype%.next
TF_BUILTIN(StringIteratorPrototypeNext, StringBuiltinsAssembler) {
Variable var_value(this, MachineRepresentation::kTagged);
Variable var_done(this, MachineRepresentation::kTagged);
......@@ -1582,8 +1585,8 @@ TF_BUILTIN(StringIteratorPrototypeNext, StringBuiltinsAssembler) {
Label throw_bad_receiver(this), next_codepoint(this), return_result(this);
Node* iterator = Parameter(0);
Node* context = Parameter(3);
Node* context = Parameter(Descriptor::kContext);
Node* iterator = Parameter(Descriptor::kReceiver);
GotoIf(TaggedIsSmi(iterator), &throw_bad_receiver);
GotoIfNot(Word32Equal(LoadInstanceType(iterator),
......
......@@ -10,22 +10,22 @@ namespace v8 {
namespace internal {
// -----------------------------------------------------------------------------
// ES6 section 19.4 Symbol Objects
// ES6 #sec-symbol-objects
// ES6 section 19.4.3.4 Symbol.prototype [ @@toPrimitive ] ( hint )
// ES6 #sec-symbol.prototype-@@toprimitive
TF_BUILTIN(SymbolPrototypeToPrimitive, CodeStubAssembler) {
Node* receiver = Parameter(0);
Node* context = Parameter(4);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Node* result = ToThisValue(context, receiver, PrimitiveType::kSymbol,
"Symbol.prototype [ @@toPrimitive ]");
Return(result);
}
// ES6 section 19.4.3.2 Symbol.prototype.toString ( )
// ES6 #sec-symbol.prototype.tostring
TF_BUILTIN(SymbolPrototypeToString, CodeStubAssembler) {
Node* receiver = Parameter(0);
Node* context = Parameter(3);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Node* value = ToThisValue(context, receiver, PrimitiveType::kSymbol,
"Symbol.prototype.toString");
......@@ -33,10 +33,10 @@ TF_BUILTIN(SymbolPrototypeToString, CodeStubAssembler) {
Return(result);
}
// ES6 section 19.4.3.3 Symbol.prototype.valueOf ( )
// ES6 #sec-symbol.prototype.valueof
TF_BUILTIN(SymbolPrototypeValueOf, CodeStubAssembler) {
Node* receiver = Parameter(0);
Node* context = Parameter(3);
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
Node* result = ToThisValue(context, receiver, PrimitiveType::kSymbol,
"Symbol.prototype.valueOf");
......
......@@ -18,10 +18,12 @@ class TypedArrayBuiltinsAssembler : public CodeStubAssembler {
: CodeStubAssembler(state) {}
protected:
void GenerateTypedArrayPrototypeGetter(const char* method_name,
void GenerateTypedArrayPrototypeGetter(Node* context, Node* receiver,
const char* method_name,
int object_offset);
template <IterationKind kIterationKind>
void GenerateTypedArrayPrototypeIterationMethod(const char* method_name);
void GenerateTypedArrayPrototypeIterationMethod(Node* context, Node* receiver,
const char* method_name,
IterationKind iteration_kind);
void LoadMapAndElementsSize(Node* const array, Variable* typed_map,
Variable* size);
......@@ -280,25 +282,25 @@ void TypedArrayBuiltinsAssembler::DoInitialize(Node* const holder, Node* length,
}
TF_BUILTIN(TypedArrayInitialize, TypedArrayBuiltinsAssembler) {
Node* const holder = Parameter(1);
Node* length = Parameter(2);
Node* const maybe_buffer = Parameter(3);
Node* const byte_offset = Parameter(4);
Node* byte_length = Parameter(5);
Node* const initialize = Parameter(6);
Node* const context = Parameter(9);
Node* const holder = Parameter(Descriptor::kHolder);
Node* length = Parameter(Descriptor::kLength);
Node* const maybe_buffer = Parameter(Descriptor::kBuffer);
Node* const byte_offset = Parameter(Descriptor::kByteOffset);
Node* byte_length = Parameter(Descriptor::kByteLength);
Node* const initialize = Parameter(Descriptor::kInitialize);
Node* const context = Parameter(Descriptor::kContext);
DoInitialize(holder, length, maybe_buffer, byte_offset, byte_length,
initialize, context);
}
// ES6 section 22.2.4.2 TypedArray ( length )
// ES6 #sec-typedarray-length
TF_BUILTIN(TypedArrayConstructByLength, TypedArrayBuiltinsAssembler) {
// We know that holder cannot be an object if this builtin was called.
Node* holder = Parameter(1);
Node* length = Parameter(2);
Node* element_size = Parameter(3);
Node* context = Parameter(6);
Node* holder = Parameter(Descriptor::kHolder);
Node* length = Parameter(Descriptor::kLength);
Node* element_size = Parameter(Descriptor::kElementSize);
Node* context = Parameter(Descriptor::kContext);
Variable maybe_buffer(this, MachineRepresentation::kTagged);
maybe_buffer.Bind(NullConstant());
......@@ -345,15 +347,15 @@ TF_BUILTIN(TypedArrayConstructByLength, TypedArrayBuiltinsAssembler) {
}
}
// ES6 section 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
// ES6 #sec-typedarray-buffer-byteoffset-length
TF_BUILTIN(TypedArrayConstructByArrayBuffer, TypedArrayBuiltinsAssembler) {
Node* const holder = Parameter(1);
Node* const buffer = Parameter(2);
Node* const byte_offset = Parameter(3);
Node* const length = Parameter(4);
Node* const element_size = Parameter(5);
Node* const holder = Parameter(Descriptor::kHolder);
Node* const buffer = Parameter(Descriptor::kBuffer);
Node* const byte_offset = Parameter(Descriptor::kByteOffset);
Node* const length = Parameter(Descriptor::kLength);
Node* const element_size = Parameter(Descriptor::kElementSize);
CSA_ASSERT(this, TaggedIsSmi(element_size));
Node* const context = Parameter(8);
Node* const context = Parameter(Descriptor::kContext);
Node* const initialize = BooleanConstant(true);
Variable new_byte_length(this, MachineRepresentation::kTagged,
......@@ -486,10 +488,7 @@ TF_BUILTIN(TypedArrayConstructByArrayBuffer, TypedArrayBuiltinsAssembler) {
}
void TypedArrayBuiltinsAssembler::GenerateTypedArrayPrototypeGetter(
const char* method_name, int object_offset) {
Node* receiver = Parameter(0);
Node* context = Parameter(3);
Node* context, Node* receiver, const char* method_name, int object_offset) {
// Check if the {receiver} is actually a JSTypedArray.
Label receiver_is_incompatible(this, Label::kDeferred);
GotoIf(TaggedIsSmi(receiver), &receiver_is_incompatible);
......@@ -520,30 +519,36 @@ void TypedArrayBuiltinsAssembler::GenerateTypedArrayPrototypeGetter(
}
}
// ES6 section 22.2.3.2 get %TypedArray%.prototype.byteLength
// ES6 #sec-get-%typedarray%.prototype.bytelength
TF_BUILTIN(TypedArrayPrototypeByteLength, TypedArrayBuiltinsAssembler) {
GenerateTypedArrayPrototypeGetter("get TypedArray.prototype.byteLength",
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
GenerateTypedArrayPrototypeGetter(context, receiver,
"get TypedArray.prototype.byteLength",
JSTypedArray::kByteLengthOffset);
}
// ES6 section 22.2.3.3 get %TypedArray%.prototype.byteOffset
// ES6 #sec-get-%typedarray%.prototype.byteoffset
TF_BUILTIN(TypedArrayPrototypeByteOffset, TypedArrayBuiltinsAssembler) {
GenerateTypedArrayPrototypeGetter("get TypedArray.prototype.byteOffset",
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
GenerateTypedArrayPrototypeGetter(context, receiver,
"get TypedArray.prototype.byteOffset",
JSTypedArray::kByteOffsetOffset);
}
// ES6 section 22.2.3.18 get %TypedArray%.prototype.length
// ES6 #sec-get-%typedarray%.prototype.length
TF_BUILTIN(TypedArrayPrototypeLength, TypedArrayBuiltinsAssembler) {
GenerateTypedArrayPrototypeGetter("get TypedArray.prototype.length",
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
GenerateTypedArrayPrototypeGetter(context, receiver,
"get TypedArray.prototype.length",
JSTypedArray::kLengthOffset);
}
template <IterationKind kIterationKind>
void TypedArrayBuiltinsAssembler::GenerateTypedArrayPrototypeIterationMethod(
const char* method_name) {
Node* receiver = Parameter(0);
Node* context = Parameter(3);
Node* context, Node* receiver, const char* method_name,
IterationKind iteration_kind) {
Label throw_bad_receiver(this, Label::kDeferred);
Label throw_typeerror(this, Label::kDeferred);
......@@ -561,7 +566,7 @@ void TypedArrayBuiltinsAssembler::GenerateTypedArrayPrototypeIterationMethod(
GotoIf(IsDetachedBuffer(receiver_buffer), &if_receiverisneutered);
Return(CreateArrayIterator(receiver, map, instance_type, context,
kIterationKind));
iteration_kind));
Variable var_message(this, MachineRepresentation::kTagged);
Bind(&throw_bad_receiver);
......@@ -583,19 +588,30 @@ void TypedArrayBuiltinsAssembler::GenerateTypedArrayPrototypeIterationMethod(
}
}
// ES6 #sec-%typedarray%.prototype.values
TF_BUILTIN(TypedArrayPrototypeValues, TypedArrayBuiltinsAssembler) {
GenerateTypedArrayPrototypeIterationMethod<IterationKind::kValues>(
"%TypedArray%.prototype.values()");
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
GenerateTypedArrayPrototypeIterationMethod(context, receiver,
"%TypedArray%.prototype.values()",
IterationKind::kValues);
}
// ES6 #sec-%typedarray%.prototype.entries
TF_BUILTIN(TypedArrayPrototypeEntries, TypedArrayBuiltinsAssembler) {
GenerateTypedArrayPrototypeIterationMethod<IterationKind::kEntries>(
"%TypedArray%.prototype.entries()");
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
GenerateTypedArrayPrototypeIterationMethod(context, receiver,
"%TypedArray%.prototype.entries()",
IterationKind::kEntries);
}
// ES6 #sec-%typedarray%.prototype.keys
TF_BUILTIN(TypedArrayPrototypeKeys, TypedArrayBuiltinsAssembler) {
GenerateTypedArrayPrototypeIterationMethod<IterationKind::kKeys>(
"%TypedArray%.prototype.keys()");
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
GenerateTypedArrayPrototypeIterationMethod(
context, receiver, "%TypedArray%.prototype.keys()", IterationKind::kKeys);
}
} // namespace internal
......
This diff is collapsed.
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