v8/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

574 lines
17 KiB
Plaintext
Raw Normal View History

#
# Autogenerated by generate-bytecode-expectations.
#
---
wrap: no
test function name: f
---
snippet: "
function f() {
for (let x = 0; x < 10; ++x) { let y = x; }
}
f();
"
frame size: 2
parameter count: 1
bytecode array length: 26
bytecodes: [
/* 10 E> */ B(StackCheck),
/* 30 S> */ B(LdaZero),
B(Star), R(1),
/* 35 S> */ B(LdaSmi), I8(10),
/* 35 E> */ B(TestLessThan), R(1), U8(0),
B(JumpIfFalse), U8(15),
/* 17 E> */ B(StackCheck),
/* 56 S> */ B(Mov), R(1), R(0),
/* 43 S> */ B(Ldar), R(0),
B(Inc), U8(1),
B(Star), R(1),
B(JumpLoop), U8(17), I8(0),
B(LdaUndefined),
/* 61 S> */ B(Return),
]
constant pool: [
]
handlers: [
]
---
snippet: "
function f() {
for (let x = 0; x < 10; ++x) { eval('1'); }
}
f();
"
frame size: 15
parameter count: 1
bytecode array length: 165
bytecodes: [
B(CreateFunctionContext), U8(0), U8(3),
B(PushContext), R(4),
B(Ldar), R(this),
B(StaCurrentContextSlot), U8(4),
B(CreateMappedArguments),
B(StaCurrentContextSlot), U8(6),
B(Ldar), R(3),
B(StaCurrentContextSlot), U8(5),
/* 10 E> */ B(StackCheck),
B(CreateBlockContext), U8(1),
B(PushContext), R(5),
B(LdaTheHole),
B(StaCurrentContextSlot), U8(4),
/* 30 S> */ B(LdaZero),
/* 30 E> */ B(StaCurrentContextSlot), U8(4),
B(LdaCurrentContextSlot), U8(4),
B(Star), R(0),
B(LdaSmi), I8(1),
B(Star), R(1),
/* 59 E> */ B(StackCheck),
B(CreateBlockContext), U8(2),
B(PushContext), R(6),
B(LdaTheHole),
B(StaCurrentContextSlot), U8(4),
B(Ldar), R(0),
B(StaCurrentContextSlot), U8(4),
B(LdaSmi), I8(1),
B(TestEqual), R(1), U8(0),
B(JumpIfFalse), U8(7),
B(LdaZero),
B(Star), R(1),
B(Jump), U8(8),
/* 43 S> */ B(LdaCurrentContextSlot), U8(4),
B(Inc), U8(1),
/* 43 E> */ B(StaCurrentContextSlot), U8(4),
B(LdaSmi), I8(1),
B(Star), R(2),
/* 35 S> */ B(LdaCurrentContextSlot), U8(4),
B(Star), R(7),
B(LdaSmi), I8(10),
/* 35 E> */ B(TestLessThan), R(7), U8(2),
B(JumpIfFalse), U8(4),
B(Jump), U8(6),
B(PopContext), R(6),
B(Jump), U8(77),
B(LdaSmi), I8(1),
B(TestEqual), R(2), U8(3),
B(JumpIfFalse), U8(54),
/* 17 E> */ B(StackCheck),
/* 48 S> */ B(LdaLookupGlobalSlot), U8(3), U8(4), U8(3),
B(Star), R(7),
B(LdaConstant), U8(4),
B(Star), R(8),
B(LdaZero),
B(Star), R(12),
B(LdaSmi), I8(31),
B(Star), R(13),
B(LdaSmi), I8(48),
B(Star), R(14),
B(Mov), R(7), R(9),
B(Mov), R(8), R(10),
B(Mov), R(closure), R(11),
B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(9), U8(6),
B(Star), R(7),
/* 48 E> */ B(CallUndefinedReceiver1), R(7), R(8), U8(6),
B(LdaZero),
B(Star), R(2),
B(LdaCurrentContextSlot), U8(4),
B(Star), R(0),
B(JumpLoop), U8(56), I8(1),
B(LdaSmi), I8(1),
/* 59 E> */ B(TestEqual), R(2), U8(8),
B(JumpIfFalse), U8(6),
B(PopContext), R(6),
B(Jump), U8(7),
B(PopContext), R(6),
B(JumpLoop), U8(123), I8(0),
B(PopContext), R(5),
B(LdaUndefined),
/* 61 S> */ B(Return),
]
constant pool: [
SCOPE_INFO_TYPE,
SCOPE_INFO_TYPE,
SCOPE_INFO_TYPE,
ONE_BYTE_INTERNALIZED_STRING_TYPE ["eval"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["1"],
]
handlers: [
]
---
snippet: "
function f() {
for (let x = 0; x < 10; ++x) { (function() { return x; })(); }
}
f();
"
frame size: 6
parameter count: 1
bytecode array length: 106
bytecodes: [
/* 10 E> */ B(StackCheck),
/* 30 S> */ B(LdaZero),
B(Star), R(0),
B(Star), R(1),
B(LdaSmi), I8(1),
B(Star), R(2),
/* 78 E> */ B(StackCheck),
B(CreateBlockContext), U8(0),
B(PushContext), R(4),
B(LdaTheHole),
B(StaCurrentContextSlot), U8(4),
B(Ldar), R(1),
B(StaCurrentContextSlot), U8(4),
B(LdaSmi), I8(1),
B(TestEqual), R(2), U8(0),
B(JumpIfFalse), U8(7),
B(LdaZero),
B(Star), R(2),
B(Jump), U8(8),
/* 43 S> */ B(LdaCurrentContextSlot), U8(4),
B(Inc), U8(1),
/* 43 E> */ B(StaCurrentContextSlot), U8(4),
B(LdaSmi), I8(1),
B(Star), R(3),
/* 35 S> */ B(LdaCurrentContextSlot), U8(4),
B(Star), R(5),
B(LdaSmi), I8(10),
/* 35 E> */ B(TestLessThan), R(5), U8(2),
B(JumpIfFalse), U8(4),
B(Jump), U8(6),
B(PopContext), R(4),
B(Jump), U8(45),
B(LdaSmi), I8(1),
B(TestEqual), R(3), U8(3),
B(JumpIfFalse), U8(22),
/* 17 E> */ B(StackCheck),
/* 48 S> */ B(CreateClosure), U8(1), U8(4), U8(2),
B(Star), R(5),
/* 74 E> */ B(CallUndefinedReceiver0), R(5), U8(5),
B(LdaZero),
B(Star), R(3),
B(LdaCurrentContextSlot), U8(4),
B(Star), R(1),
B(JumpLoop), U8(24), I8(1),
B(LdaSmi), I8(1),
/* 78 E> */ B(TestEqual), R(3), U8(7),
B(JumpIfFalse), U8(6),
B(PopContext), R(4),
B(Jump), U8(7),
B(PopContext), R(4),
B(JumpLoop), U8(91), I8(0),
B(LdaUndefined),
/* 80 S> */ B(Return),
]
constant pool: [
SCOPE_INFO_TYPE,
SHARED_FUNCTION_INFO_TYPE,
]
handlers: [
]
---
snippet: "
function f() {
for (let { x, y } = { x: 0, y: 3 }; y > 0; --y) { let z = x + y; }
}
f();
"
frame size: 6
parameter count: 1
bytecode array length: 68
bytecodes: [
/* 10 E> */ B(StackCheck),
B(CreateObjectLiteral), U8(0), U8(0), U8(41), R(4),
B(Mov), R(4), R(3),
B(Ldar), R(3),
B(JumpIfUndefined), U8(6),
B(Ldar), R(3),
B(JumpIfNotNull), U8(16),
B(LdaSmi), I8(81),
B(Star), R(4),
B(LdaConstant), U8(1),
B(Star), R(5),
B(CallRuntime), U16(Runtime::kNewTypeError), R(4), U8(2),
[parser] Better error message when destructuring against undefined/null Previously, when destructuring against null or undefined we would print: d8> var { x } = null (d8):1: TypeError: Cannot match against 'undefined' or 'null'. var { x } = null ^ TypeError: Cannot match against 'undefined' or 'null'. at (d8):1:1 The above message uses the term "match" which isn't a common term in JavaScript to describe destructuring. This message also doesn't provide the name of the property that fails destructuring. This patch changes the error message to be: d8> var { x } = null; (d8):1: TypeError: Cannot destructure property `x` of 'undefined' or 'null'. var { x } = null; ^ TypeError: Cannot destructure property `x` of 'undefined' or 'null'. at (d8):1:1 This patch changes the message to say "destructure" instead of "match". This patch adds support for printing property names that are string literals. We iterate through every property and pick the first string literal property name if it exists. This provides at least some feedback to the developer. This patch also makes the pointer point to the position of the property name that fails destructuring. For computed and numeric property names, we print a generic error: d8> var { 1: x } = null (d8):1: TypeError: Cannot destructure against 'undefined' or 'null'. var { 1: x } = null ^ TypeError: Cannot destructure against 'undefined' or 'null'. at (d8):1:1 Bug: v8:6499 Change-Id: I35b1ac749489828686f042975294b9926e2dfc53 Reviewed-on: https://chromium-review.googlesource.com/537341 Reviewed-by: Adam Klein <adamk@chromium.org> Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org> Cr-Commit-Position: refs/heads/master@{#45965}
2017-06-15 21:24:37 +00:00
/* 28 E> */ B(Throw),
/* 37 S> */ B(LdaNamedProperty), R(3), U8(1), U8(1),
B(Star), R(1),
/* 37 S> */ B(LdaNamedProperty), R(3), U8(2), U8(3),
B(Star), R(2),
/* 55 S> */ B(LdaZero),
/* 55 E> */ B(TestGreaterThan), R(2), U8(5),
B(JumpIfFalse), U8(19),
/* 17 E> */ B(StackCheck),
/* 75 S> */ B(Ldar), R(2),
/* 77 E> */ B(Add), R(1), U8(6),
B(Star), R(0),
/* 62 S> */ B(Ldar), R(2),
B(Dec), U8(7),
B(Star), R(2),
B(JumpLoop), U8(20), I8(0),
B(LdaUndefined),
/* 84 S> */ B(Return),
]
constant pool: [
OBJECT_BOILERPLATE_DESCRIPTION_TYPE,
ONE_BYTE_INTERNALIZED_STRING_TYPE ["x"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["y"],
]
handlers: [
]
---
snippet: "
function* f() {
for (let x = 0; x < 10; ++x) { let y = x; }
}
f();
"
frame size: 5
parameter count: 1
bytecode array length: 67
bytecodes: [
B(SwitchOnGeneratorState), R(2), U8(0), U8(1),
B(Mov), R(closure), R(3),
B(Mov), R(this), R(4),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(3), U8(2),
B(Star), R(2),
/* 11 E> */ B(StackCheck),
/* 11 E> */ B(SuspendGenerator), R(2), R(0), U8(3), U8(0),
B(ResumeGenerator), R(2), R(0), U8(3),
B(Star), R(3),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(2), U8(1),
B(SwitchOnSmiNoFeedback), U8(1), U8(2), I8(0),
B(Ldar), R(3),
/* 11 E> */ B(Throw),
B(Ldar), R(3),
/* 62 S> */ B(Return),
/* 31 S> */ B(LdaZero),
B(Star), R(1),
/* 36 S> */ B(LdaSmi), I8(10),
/* 36 E> */ B(TestLessThan), R(1), U8(0),
B(JumpIfFalse), U8(15),
/* 18 E> */ B(StackCheck),
/* 57 S> */ B(Mov), R(1), R(0),
/* 44 S> */ B(Ldar), R(0),
B(Inc), U8(1),
B(Star), R(1),
B(JumpLoop), U8(17), I8(0),
B(LdaUndefined),
/* 62 S> */ B(Return),
]
constant pool: [
Smi [22],
Smi [10],
Smi [7],
]
handlers: [
]
---
snippet: "
function* f() {
for (let x = 0; x < 10; ++x) yield x;
}
f();
"
frame size: 4
parameter count: 1
bytecode array length: 99
bytecodes: [
B(SwitchOnGeneratorState), R(1), U8(0), U8(2),
B(Mov), R(closure), R(2),
B(Mov), R(this), R(3),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(2), U8(2),
B(Star), R(1),
/* 11 E> */ B(StackCheck),
/* 11 E> */ B(SuspendGenerator), R(1), R(0), U8(2), U8(0),
B(ResumeGenerator), R(1), R(0), U8(2),
B(Star), R(2),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
B(Ldar), R(2),
/* 11 E> */ B(Throw),
B(Ldar), R(2),
/* 56 S> */ B(Return),
/* 31 S> */ B(LdaZero),
B(Star), R(0),
/* 36 S> */ B(LdaSmi), I8(10),
/* 36 E> */ B(TestLessThan), R(0), U8(0),
B(JumpIfFalse), U8(47),
/* 18 E> */ B(StackCheck),
/* 47 S> */ B(LdaFalse),
B(Star), R(3),
B(Mov), R(0), R(2),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(2), U8(2),
/* 47 E> */ B(SuspendGenerator), R(1), R(0), U8(2), U8(1),
B(ResumeGenerator), R(1), R(0), U8(2),
B(Star), R(2),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(SwitchOnSmiNoFeedback), U8(4), U8(2), I8(0),
B(Ldar), R(2),
/* 47 E> */ B(Throw),
B(Ldar), R(2),
/* 56 S> */ B(Return),
/* 44 S> */ B(Ldar), R(0),
B(Inc), U8(1),
B(Star), R(0),
B(JumpLoop), U8(49), I8(0),
B(LdaUndefined),
/* 56 S> */ B(Return),
]
constant pool: [
Smi [22],
Smi [68],
Smi [10],
Smi [7],
Smi [10],
Smi [7],
]
handlers: [
]
---
snippet: "
async function f() {
for (let x = 0; x < 10; ++x) { let y = x; }
}
f();
"
frame size: 12
parameter count: 1
bytecode array length: 140
bytecodes: [
/* 16 E> */ B(StackCheck),
B(CallJSRuntime), U8(%async_function_promise_create), R(0), U8(0),
B(Star), R(3),
B(Mov), R(context), R(6),
B(Mov), R(context), R(7),
/* 36 S> */ B(LdaZero),
B(Star), R(1),
/* 41 S> */ B(LdaSmi), I8(10),
/* 41 E> */ B(TestLessThan), R(1), U8(0),
B(JumpIfFalse), U8(15),
/* 23 E> */ B(StackCheck),
/* 62 S> */ B(Mov), R(1), R(0),
/* 49 S> */ B(Ldar), R(0),
B(Inc), U8(1),
B(Star), R(1),
B(JumpLoop), U8(17), I8(0),
B(LdaUndefined),
B(Star), R(9),
B(Mov), R(3), R(8),
[builtins] Refactor the promise resolution and rejection logic. This introduces dedicated builtins - FulfillPromise, - RejectPromise, and - ResolvePromise, which perform the corresponding operations from the language specification, and removes the redundant entry points and the excessive inlining of these operations into other builtins. We also add the same logic on the C++ side, so that we don't need to go into JavaScript land when resolving/rejecting from the API. The C++ side has a complete implementation, including full support for the debugger and the current PromiseHook machinery. This is to avoid constantly crossing the boundary for those cases, and to also simplify the CSA side (and soon the TurboFan side), where we only do the fast-path and bail out to the runtime for the general handling. On top of this we introduce %_RejectPromise and %_ResolvePromise, which are entry points used by the bytecode and parser desugarings for async functions, and also used by the V8 Extras API. Thanks to this we can uniformly optimize these in TurboFan, where we have corresponding operators JSRejectPromise and JSResolvePromise, which currently just call into the builtins, but middle-term can be further optimized, i.e. to skip the "then" lookup for JSResolvePromise when we know something about the resolution. In TurboFan we can also already inline the default PromiseCapability [[Reject]] and [[Resolve]] functions, although this is not as effective as it can be right now, until we have inlining support for the Promise constructor (being worked on by petermarshall@ right now) and/or SFI based CALL_IC feedback. Overall this change is meant as a refactoring without significant performance impact anywhere; it seems to improve performance of simple async functions a bit, but otherwise is neutral. Bug: v8:7253 Change-Id: Id0b979f9b2843560e38cd8df4b02627dad4b6d8c Reviewed-on: https://chromium-review.googlesource.com/911632 Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Reviewed-by: Georg Neis <neis@chromium.org> Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Cr-Commit-Position: refs/heads/master@{#51260}
2018-02-12 19:10:29 +00:00
/* 49 E> */ B(InvokeIntrinsic), U8(Runtime::k_ResolvePromise), R(8), U8(2),
B(LdaZero),
B(Star), R(4),
B(Mov), R(3), R(5),
B(Jump), U8(55),
B(Jump), U8(39),
B(Star), R(8),
B(CreateCatchContext), R(8), U8(0),
B(Star), R(7),
B(LdaTheHole),
B(SetPendingMessage),
B(Ldar), R(7),
B(PushContext), R(8),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(10),
B(LdaFalse),
B(Star), R(11),
B(Mov), R(3), R(9),
[builtins] Refactor the promise resolution and rejection logic. This introduces dedicated builtins - FulfillPromise, - RejectPromise, and - ResolvePromise, which perform the corresponding operations from the language specification, and removes the redundant entry points and the excessive inlining of these operations into other builtins. We also add the same logic on the C++ side, so that we don't need to go into JavaScript land when resolving/rejecting from the API. The C++ side has a complete implementation, including full support for the debugger and the current PromiseHook machinery. This is to avoid constantly crossing the boundary for those cases, and to also simplify the CSA side (and soon the TurboFan side), where we only do the fast-path and bail out to the runtime for the general handling. On top of this we introduce %_RejectPromise and %_ResolvePromise, which are entry points used by the bytecode and parser desugarings for async functions, and also used by the V8 Extras API. Thanks to this we can uniformly optimize these in TurboFan, where we have corresponding operators JSRejectPromise and JSResolvePromise, which currently just call into the builtins, but middle-term can be further optimized, i.e. to skip the "then" lookup for JSResolvePromise when we know something about the resolution. In TurboFan we can also already inline the default PromiseCapability [[Reject]] and [[Resolve]] functions, although this is not as effective as it can be right now, until we have inlining support for the Promise constructor (being worked on by petermarshall@ right now) and/or SFI based CALL_IC feedback. Overall this change is meant as a refactoring without significant performance impact anywhere; it seems to improve performance of simple async functions a bit, but otherwise is neutral. Bug: v8:7253 Change-Id: Id0b979f9b2843560e38cd8df4b02627dad4b6d8c Reviewed-on: https://chromium-review.googlesource.com/911632 Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Reviewed-by: Georg Neis <neis@chromium.org> Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Cr-Commit-Position: refs/heads/master@{#51260}
2018-02-12 19:10:29 +00:00
B(InvokeIntrinsic), U8(Runtime::k_RejectPromise), R(9), U8(3),
B(PopContext), R(8),
B(LdaZero),
B(Star), R(4),
B(Mov), R(3), R(5),
B(Jump), U8(16),
B(LdaSmi), I8(-1),
B(Star), R(5),
B(Star), R(4),
B(Jump), U8(8),
B(Star), R(5),
B(LdaSmi), I8(1),
B(Star), R(4),
B(LdaTheHole),
B(SetPendingMessage),
B(Star), R(6),
B(LdaFalse),
B(Star), R(8),
B(Mov), R(3), R(7),
B(CallJSRuntime), U8(%async_function_promise_release), R(7), U8(2),
B(Ldar), R(6),
B(SetPendingMessage),
B(Ldar), R(4),
B(SwitchOnSmiNoFeedback), U8(1), U8(2), I8(0),
B(Jump), U8(8),
B(Ldar), R(5),
/* 67 S> */ B(Return),
B(Ldar), R(5),
B(ReThrow),
B(LdaUndefined),
/* 67 S> */ B(Return),
]
constant pool: [
SCOPE_INFO_TYPE,
Smi [6],
Smi [9],
]
handlers: [
[10, 93, 101],
[13, 54, 56],
]
---
snippet: "
async function f() {
for (let x = 0; x < 10; ++x) await x;
}
f();
"
frame size: 11
parameter count: 1
bytecode array length: 191
bytecodes: [
B(SwitchOnGeneratorState), R(1), U8(0), U8(1),
B(Mov), R(closure), R(3),
B(Mov), R(this), R(4),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(3), U8(2),
B(Star), R(1),
/* 16 E> */ B(StackCheck),
B(CallJSRuntime), U8(%async_function_promise_create), R(0), U8(0),
B(Star), R(2),
B(Mov), R(context), R(5),
B(Mov), R(context), R(6),
/* 36 S> */ B(LdaZero),
B(Star), R(0),
/* 41 S> */ B(LdaSmi), I8(10),
/* 41 E> */ B(TestLessThan), R(0), U8(0),
B(JumpIfFalse), U8(50),
/* 23 E> */ B(StackCheck),
/* 52 S> */ B(Mov), R(1), R(7),
B(Mov), R(0), R(8),
B(Mov), R(2), R(9),
B(CallJSRuntime), U8(%async_function_await_uncaught), R(7), U8(3),
/* 52 E> */ B(SuspendGenerator), R(1), R(0), U8(7), U8(0),
B(ResumeGenerator), R(1), R(0), U8(7),
B(Star), R(7),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(Star), R(8),
B(LdaZero),
B(TestReferenceEqual), R(8),
B(JumpIfTrue), U8(5),
B(Ldar), R(7),
B(ReThrow),
/* 49 S> */ B(Ldar), R(0),
B(Inc), U8(1),
B(Star), R(0),
B(JumpLoop), U8(52), I8(0),
B(LdaUndefined),
B(Star), R(8),
B(Mov), R(2), R(7),
[builtins] Refactor the promise resolution and rejection logic. This introduces dedicated builtins - FulfillPromise, - RejectPromise, and - ResolvePromise, which perform the corresponding operations from the language specification, and removes the redundant entry points and the excessive inlining of these operations into other builtins. We also add the same logic on the C++ side, so that we don't need to go into JavaScript land when resolving/rejecting from the API. The C++ side has a complete implementation, including full support for the debugger and the current PromiseHook machinery. This is to avoid constantly crossing the boundary for those cases, and to also simplify the CSA side (and soon the TurboFan side), where we only do the fast-path and bail out to the runtime for the general handling. On top of this we introduce %_RejectPromise and %_ResolvePromise, which are entry points used by the bytecode and parser desugarings for async functions, and also used by the V8 Extras API. Thanks to this we can uniformly optimize these in TurboFan, where we have corresponding operators JSRejectPromise and JSResolvePromise, which currently just call into the builtins, but middle-term can be further optimized, i.e. to skip the "then" lookup for JSResolvePromise when we know something about the resolution. In TurboFan we can also already inline the default PromiseCapability [[Reject]] and [[Resolve]] functions, although this is not as effective as it can be right now, until we have inlining support for the Promise constructor (being worked on by petermarshall@ right now) and/or SFI based CALL_IC feedback. Overall this change is meant as a refactoring without significant performance impact anywhere; it seems to improve performance of simple async functions a bit, but otherwise is neutral. Bug: v8:7253 Change-Id: Id0b979f9b2843560e38cd8df4b02627dad4b6d8c Reviewed-on: https://chromium-review.googlesource.com/911632 Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Reviewed-by: Georg Neis <neis@chromium.org> Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Cr-Commit-Position: refs/heads/master@{#51260}
2018-02-12 19:10:29 +00:00
/* 49 E> */ B(InvokeIntrinsic), U8(Runtime::k_ResolvePromise), R(7), U8(2),
B(LdaZero),
B(Star), R(3),
B(Mov), R(2), R(4),
B(Jump), U8(55),
B(Jump), U8(39),
B(Star), R(7),
B(CreateCatchContext), R(7), U8(1),
B(Star), R(6),
B(LdaTheHole),
B(SetPendingMessage),
B(Ldar), R(6),
B(PushContext), R(7),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(9),
B(LdaFalse),
B(Star), R(10),
B(Mov), R(2), R(8),
[builtins] Refactor the promise resolution and rejection logic. This introduces dedicated builtins - FulfillPromise, - RejectPromise, and - ResolvePromise, which perform the corresponding operations from the language specification, and removes the redundant entry points and the excessive inlining of these operations into other builtins. We also add the same logic on the C++ side, so that we don't need to go into JavaScript land when resolving/rejecting from the API. The C++ side has a complete implementation, including full support for the debugger and the current PromiseHook machinery. This is to avoid constantly crossing the boundary for those cases, and to also simplify the CSA side (and soon the TurboFan side), where we only do the fast-path and bail out to the runtime for the general handling. On top of this we introduce %_RejectPromise and %_ResolvePromise, which are entry points used by the bytecode and parser desugarings for async functions, and also used by the V8 Extras API. Thanks to this we can uniformly optimize these in TurboFan, where we have corresponding operators JSRejectPromise and JSResolvePromise, which currently just call into the builtins, but middle-term can be further optimized, i.e. to skip the "then" lookup for JSResolvePromise when we know something about the resolution. In TurboFan we can also already inline the default PromiseCapability [[Reject]] and [[Resolve]] functions, although this is not as effective as it can be right now, until we have inlining support for the Promise constructor (being worked on by petermarshall@ right now) and/or SFI based CALL_IC feedback. Overall this change is meant as a refactoring without significant performance impact anywhere; it seems to improve performance of simple async functions a bit, but otherwise is neutral. Bug: v8:7253 Change-Id: Id0b979f9b2843560e38cd8df4b02627dad4b6d8c Reviewed-on: https://chromium-review.googlesource.com/911632 Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Reviewed-by: Georg Neis <neis@chromium.org> Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Cr-Commit-Position: refs/heads/master@{#51260}
2018-02-12 19:10:29 +00:00
B(InvokeIntrinsic), U8(Runtime::k_RejectPromise), R(8), U8(3),
B(PopContext), R(7),
B(LdaZero),
B(Star), R(3),
B(Mov), R(2), R(4),
B(Jump), U8(16),
B(LdaSmi), I8(-1),
B(Star), R(4),
B(Star), R(3),
B(Jump), U8(8),
B(Star), R(4),
B(LdaSmi), I8(1),
B(Star), R(3),
B(LdaTheHole),
B(SetPendingMessage),
B(Star), R(5),
B(LdaTrue),
B(Star), R(7),
B(Mov), R(2), R(6),
B(CallJSRuntime), U8(%async_function_promise_release), R(6), U8(2),
B(Ldar), R(5),
B(SetPendingMessage),
B(Ldar), R(3),
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
B(Jump), U8(8),
B(Ldar), R(4),
/* 61 S> */ B(Return),
B(Ldar), R(4),
B(ReThrow),
B(LdaUndefined),
/* 61 S> */ B(Return),
]
constant pool: [
Smi [58],
SCOPE_INFO_TYPE,
Smi [6],
Smi [9],
]
handlers: [
[26, 144, 152],
[29, 105, 107],
]