Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: src/builtins/builtins-promise.cc

Issue 2705163005: [csa] Add Unreachable() and use it after throw sites (Closed)
Patch Set: Rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/builtins/builtins-generator.cc ('k') | src/builtins/builtins-regexp.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/builtins/builtins-promise.h" 5 #include "src/builtins/builtins-promise.h"
6 #include "src/builtins/builtins-constructor.h" 6 #include "src/builtins/builtins-constructor.h"
7 #include "src/builtins/builtins-utils.h" 7 #include "src/builtins/builtins-utils.h"
8 #include "src/builtins/builtins.h" 8 #include "src/builtins/builtins.h"
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/code-stub-assembler.h" 10 #include "src/code-stub-assembler.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 Bind(&if_notcallable); 172 Bind(&if_notcallable);
173 Node* message = SmiConstant(MessageTemplate::kPromiseNonCallable); 173 Node* message = SmiConstant(MessageTemplate::kPromiseNonCallable);
174 StoreObjectField(capability, JSPromiseCapability::kPromiseOffset, 174 StoreObjectField(capability, JSPromiseCapability::kPromiseOffset,
175 UndefinedConstant()); 175 UndefinedConstant());
176 StoreObjectField(capability, JSPromiseCapability::kResolveOffset, 176 StoreObjectField(capability, JSPromiseCapability::kResolveOffset,
177 UndefinedConstant()); 177 UndefinedConstant());
178 StoreObjectField(capability, JSPromiseCapability::kRejectOffset, 178 StoreObjectField(capability, JSPromiseCapability::kRejectOffset,
179 UndefinedConstant()); 179 UndefinedConstant());
180 CallRuntime(Runtime::kThrowTypeError, context, message); 180 CallRuntime(Runtime::kThrowTypeError, context, message);
181 var_result.Bind(UndefinedConstant()); 181 Unreachable();
182 Goto(&out);
183 } 182 }
184 183
185 Bind(&out); 184 Bind(&out);
186 return var_result.value(); 185 return var_result.value();
187 } 186 }
188 187
189 Node* PromiseBuiltinsAssembler::CreatePromiseContext(Node* native_context, 188 Node* PromiseBuiltinsAssembler::CreatePromiseContext(Node* native_context,
190 int slots) { 189 int slots) {
191 DCHECK_GE(slots, Context::MIN_CONTEXT_SLOTS); 190 DCHECK_GE(slots, Context::MIN_CONTEXT_SLOTS);
192 191
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // The {value} is not a compatible receiver for this method. 243 // The {value} is not a compatible receiver for this method.
245 Bind(&throw_exception); 244 Bind(&throw_exception);
246 { 245 {
247 Node* const method = 246 Node* const method =
248 method_name == nullptr 247 method_name == nullptr
249 ? UndefinedConstant() 248 ? UndefinedConstant()
250 : HeapConstant( 249 : HeapConstant(
251 isolate()->factory()->NewStringFromAsciiChecked(method_name)); 250 isolate()->factory()->NewStringFromAsciiChecked(method_name));
252 Node* const message_id = SmiConstant(msg_template); 251 Node* const message_id = SmiConstant(msg_template);
253 CallRuntime(Runtime::kThrowTypeError, context, message_id, method); 252 CallRuntime(Runtime::kThrowTypeError, context, message_id, method);
254 var_value_map.Bind(UndefinedConstant()); 253 Unreachable();
255 Goto(&out); // Never reached.
256 } 254 }
257 255
258 Bind(&out); 256 Bind(&out);
259 return var_value_map.value(); 257 return var_value_map.value();
260 } 258 }
261 259
262 Node* PromiseBuiltinsAssembler::PromiseHasHandler(Node* promise) { 260 Node* PromiseBuiltinsAssembler::PromiseHasHandler(Node* promise) {
263 Node* const flags = LoadObjectField(promise, JSPromise::kFlagsOffset); 261 Node* const flags = LoadObjectField(promise, JSPromise::kFlagsOffset);
264 return IsSetWord(SmiUntag(flags), 1 << JSPromise::kHasHandlerBit); 262 return IsSetWord(SmiUntag(flags), 1 << JSPromise::kHasHandlerBit);
265 } 263 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 &throw_error); 316 &throw_error);
319 var_result.Bind(species); 317 var_result.Bind(species);
320 Goto(&out); 318 Goto(&out);
321 319
322 // 8. Throw a TypeError exception. 320 // 8. Throw a TypeError exception.
323 Bind(&throw_error); 321 Bind(&throw_error);
324 { 322 {
325 Node* const message_id = 323 Node* const message_id =
326 SmiConstant(MessageTemplate::kSpeciesNotConstructor); 324 SmiConstant(MessageTemplate::kSpeciesNotConstructor);
327 CallRuntime(Runtime::kThrowTypeError, context, message_id); 325 CallRuntime(Runtime::kThrowTypeError, context, message_id);
328 Goto(&out); 326 Unreachable();
329 } 327 }
330 328
331 Bind(&out); 329 Bind(&out);
332 return var_result.value(); 330 return var_result.value();
333 } 331 }
334 332
335 void PromiseBuiltinsAssembler::AppendPromiseCallback(int offset, Node* promise, 333 void PromiseBuiltinsAssembler::AppendPromiseCallback(int offset, Node* promise,
336 Node* value) { 334 Node* value) {
337 Node* elements = LoadObjectField(promise, offset); 335 Node* elements = LoadObjectField(promise, offset);
338 Node* length = LoadFixedArrayBaseLength(elements); 336 Node* length = LoadFixedArrayBaseLength(elements);
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 } 1106 }
1109 Bind(&out); 1107 Bind(&out);
1110 Return(var_result.value()); 1108 Return(var_result.value());
1111 } 1109 }
1112 1110
1113 // 1. If NewTarget is undefined, throw a TypeError exception. 1111 // 1. If NewTarget is undefined, throw a TypeError exception.
1114 Bind(&if_targetisundefined); 1112 Bind(&if_targetisundefined);
1115 { 1113 {
1116 Node* const message_id = SmiConstant(MessageTemplate::kNotAPromise); 1114 Node* const message_id = SmiConstant(MessageTemplate::kNotAPromise);
1117 CallRuntime(Runtime::kThrowTypeError, context, message_id, new_target); 1115 CallRuntime(Runtime::kThrowTypeError, context, message_id, new_target);
1118 Return(UndefinedConstant()); // Never reached. 1116 Unreachable();
1119 } 1117 }
1120 1118
1121 // 2. If IsCallable(executor) is false, throw a TypeError exception. 1119 // 2. If IsCallable(executor) is false, throw a TypeError exception.
1122 Bind(&if_notcallable); 1120 Bind(&if_notcallable);
1123 { 1121 {
1124 Node* const message_id = 1122 Node* const message_id =
1125 SmiConstant(MessageTemplate::kResolverNotAFunction); 1123 SmiConstant(MessageTemplate::kResolverNotAFunction);
1126 CallRuntime(Runtime::kThrowTypeError, context, message_id, executor); 1124 CallRuntime(Runtime::kThrowTypeError, context, message_id, executor);
1127 Return(UndefinedConstant()); // Never reached. 1125 Unreachable();
1128 } 1126 }
1129 1127
1130 // Silently fail if the stack looks fishy. 1128 // Silently fail if the stack looks fishy.
1131 Bind(&if_noaccess); 1129 Bind(&if_noaccess);
1132 { 1130 {
1133 Node* const counter_id = 1131 Node* const counter_id =
1134 SmiConstant(v8::Isolate::kPromiseConstructorReturnedUndefined); 1132 SmiConstant(v8::Isolate::kPromiseConstructorReturnedUndefined);
1135 CallRuntime(Runtime::kIncrementUseCounter, context, counter_id); 1133 CallRuntime(Runtime::kIncrementUseCounter, context, counter_id);
1136 Return(UndefinedConstant()); 1134 Return(UndefinedConstant());
1137 } 1135 }
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 UndefinedConstant()), 1486 UndefinedConstant()),
1489 &if_alreadyinvoked); 1487 &if_alreadyinvoked);
1490 1488
1491 StoreObjectField(capability, JSPromiseCapability::kResolveOffset, resolve); 1489 StoreObjectField(capability, JSPromiseCapability::kResolveOffset, resolve);
1492 StoreObjectField(capability, JSPromiseCapability::kRejectOffset, reject); 1490 StoreObjectField(capability, JSPromiseCapability::kRejectOffset, reject);
1493 1491
1494 Return(UndefinedConstant()); 1492 Return(UndefinedConstant());
1495 1493
1496 Bind(&if_alreadyinvoked); 1494 Bind(&if_alreadyinvoked);
1497 Node* message = SmiConstant(MessageTemplate::kPromiseExecutorAlreadyInvoked); 1495 Node* message = SmiConstant(MessageTemplate::kPromiseExecutorAlreadyInvoked);
1498 Return(CallRuntime(Runtime::kThrowTypeError, context, message)); 1496 CallRuntime(Runtime::kThrowTypeError, context, message);
1497 Unreachable();
1499 } 1498 }
1500 1499
1501 TF_BUILTIN(NewPromiseCapability, PromiseBuiltinsAssembler) { 1500 TF_BUILTIN(NewPromiseCapability, PromiseBuiltinsAssembler) {
1502 Node* constructor = Parameter(1); 1501 Node* constructor = Parameter(1);
1503 Node* debug_event = Parameter(2); 1502 Node* debug_event = Parameter(2);
1504 Node* context = Parameter(5); 1503 Node* context = Parameter(5);
1505 1504
1506 CSA_ASSERT_JS_ARGC_EQ(this, 2); 1505 CSA_ASSERT_JS_ARGC_EQ(this, 2);
1507 1506
1508 Return(NewPromiseCapability(context, constructor, debug_event)); 1507 Return(NewPromiseCapability(context, constructor, debug_event));
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 promise_capability, UndefinedConstant(), 1644 promise_capability, UndefinedConstant(),
1646 UndefinedConstant()); 1645 UndefinedConstant());
1647 Return(promise_capability); 1646 Return(promise_capability);
1648 } 1647 }
1649 1648
1650 TF_BUILTIN(PromiseThrowerFinally, PromiseBuiltinsAssembler) { 1649 TF_BUILTIN(PromiseThrowerFinally, PromiseBuiltinsAssembler) {
1651 Node* const context = Parameter(3); 1650 Node* const context = Parameter(3);
1652 1651
1653 Node* const reason = LoadContextElement(context, kOnFinallySlot); 1652 Node* const reason = LoadContextElement(context, kOnFinallySlot);
1654 CallRuntime(Runtime::kThrow, context, reason); 1653 CallRuntime(Runtime::kThrow, context, reason);
1655 Return(UndefinedConstant()); 1654 Unreachable();
1656 } 1655 }
1657 1656
1658 Node* PromiseBuiltinsAssembler::CreateThrowerFunctionContext( 1657 Node* PromiseBuiltinsAssembler::CreateThrowerFunctionContext(
1659 Node* reason, Node* native_context) { 1658 Node* reason, Node* native_context) {
1660 Node* const context = 1659 Node* const context =
1661 CreatePromiseContext(native_context, kOnFinallyContextLength); 1660 CreatePromiseContext(native_context, kOnFinallyContextLength);
1662 StoreContextElementNoWriteBarrier(context, kOnFinallySlot, reason); 1661 StoreContextElementNoWriteBarrier(context, kOnFinallySlot, reason);
1663 return context; 1662 return context;
1664 } 1663 }
1665 1664
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1773 // 5. Return ? Invoke(promise, "then", « thenFinally, catchFinally »). 1772 // 5. Return ? Invoke(promise, "then", « thenFinally, catchFinally »).
1774 Node* const result = 1773 Node* const result =
1775 CallJS(call_callable, context, then, promise, var_then_finally.value(), 1774 CallJS(call_callable, context, then, promise, var_then_finally.value(),
1776 var_catch_finally.value()); 1775 var_catch_finally.value());
1777 Return(result); 1776 Return(result);
1778 } 1777 }
1779 } 1778 }
1780 1779
1781 } // namespace internal 1780 } // namespace internal
1782 } // namespace v8 1781 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins-generator.cc ('k') | src/builtins/builtins-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698