| Index: src/compiler/escape-analysis-reducer.cc
|
| diff --git a/src/compiler/escape-analysis-reducer.cc b/src/compiler/escape-analysis-reducer.cc
|
| index a2b53c0b875b5b54e9feac606e3939cab6f9226a..bcd91e302fb1591249760eb35ff2648bbd1fe9f5 100644
|
| --- a/src/compiler/escape-analysis-reducer.cc
|
| +++ b/src/compiler/escape-analysis-reducer.cc
|
| @@ -97,6 +97,22 @@ Reduction EscapeAnalysisReducer::Reduce(Node* node) {
|
| return NoChange();
|
| }
|
|
|
| +namespace {
|
| +
|
| +Node* MaybeGuard(JSGraph* jsgraph, Node* original, Node* replacement) {
|
| + // We might need to guard the replacement if the type of the {replacement}
|
| + // node is not in a sub-type relation to the type of the the {original} node.
|
| + Type* const replacement_type = NodeProperties::GetType(replacement);
|
| + Type* const original_type = NodeProperties::GetType(original);
|
| + if (!replacement_type->Is(original_type)) {
|
| + Node* const control = NodeProperties::GetControlInput(original);
|
| + replacement = jsgraph->graph()->NewNode(
|
| + jsgraph->common()->TypeGuard(original_type), replacement, control);
|
| + }
|
| + return replacement;
|
| +}
|
| +
|
| +} // namespace
|
|
|
| Reduction EscapeAnalysisReducer::ReduceLoad(Node* node) {
|
| DCHECK(node->opcode() == IrOpcode::kLoadField ||
|
| @@ -108,6 +124,7 @@ Reduction EscapeAnalysisReducer::ReduceLoad(Node* node) {
|
| isolate()->counters()->turbo_escape_loads_replaced()->Increment();
|
| TRACE("Replaced #%d (%s) with #%d (%s)\n", node->id(),
|
| node->op()->mnemonic(), rep->id(), rep->op()->mnemonic());
|
| + rep = MaybeGuard(jsgraph(), node, rep);
|
| ReplaceWithValue(node, rep);
|
| return Replace(rep);
|
| }
|
|
|