Skip to content

Commit bdcc750

Browse files
sigurdschneiderCommit Bot
authored andcommitted
[torque] Check for prototype before loading it
Add a missing check for a prototype to GetDerivedMap. Bug: chromium:999310 Change-Id: I99c342a53e3b95bb7b624ff14c1c40576ee629df Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1776092 Auto-Submit: Sigurd Schneider <[email protected]> Commit-Queue: Tobias Tebbi <[email protected]> Reviewed-by: Tobias Tebbi <[email protected]> Reviewed-by: Toon Verwaest <[email protected]> Cr-Commit-Position: refs/heads/master@{#63473}
1 parent 2a099bf commit bdcc750

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/builtins/base.tq

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,16 @@ macro NewJSObject(implicit context: Context)(): JSObject {
368368
};
369369
}
370370

371+
extern macro HasPrototypeSlot(JSFunction): bool;
372+
371373
macro GetDerivedMap(implicit context: Context)(
372374
target: JSFunction, newTarget: JSReceiver): Map {
373375
try {
374376
const constructor = Cast<JSFunction>(newTarget) otherwise SlowPath;
377+
if (!HasPrototypeSlot(constructor)) {
378+
goto SlowPath;
379+
}
380+
assert(IsConstructor(constructor));
375381
const map =
376382
Cast<Map>(constructor.prototype_or_initial_map) otherwise SlowPath;
377383
if (LoadConstructorOrBackPointer(map) != target) {

src/codegen/code-stub-assembler.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2767,6 +2767,11 @@ TNode<BoolT> CodeStubAssembler::IsGeneratorFunction(
27672767
Int32Constant(FunctionKind::kConciseGeneratorMethod))));
27682768
}
27692769

2770+
TNode<BoolT> CodeStubAssembler::HasPrototypeSlot(TNode<JSFunction> function) {
2771+
return TNode<BoolT>::UncheckedCast(IsSetWord32<Map::HasPrototypeSlotBit>(
2772+
LoadMapBitField(LoadMap(function))));
2773+
}
2774+
27702775
TNode<BoolT> CodeStubAssembler::HasPrototypeProperty(TNode<JSFunction> function,
27712776
TNode<Map> map) {
27722777
// (has_prototype_slot() && IsConstructor()) ||

src/codegen/code-stub-assembler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
14351435
TNode<Map> LoadJSArrayElementsMap(SloppyTNode<Int32T> kind,
14361436
SloppyTNode<Context> native_context);
14371437

1438+
TNode<BoolT> HasPrototypeSlot(TNode<JSFunction> function);
14381439
TNode<BoolT> IsGeneratorFunction(TNode<JSFunction> function);
14391440
TNode<BoolT> HasPrototypeProperty(TNode<JSFunction> function, TNode<Map> map);
14401441
void GotoIfPrototypeRequiresRuntimeLookup(TNode<JSFunction> function,

0 commit comments

Comments
 (0)