diff --git a/deps/v8/src/crankshaft/hydrogen-instructions.cc b/deps/v8/src/crankshaft/hydrogen-instructions.cc index a9c6228cd35c09..729fc588bcb7c2 100644 --- a/deps/v8/src/crankshaft/hydrogen-instructions.cc +++ b/deps/v8/src/crankshaft/hydrogen-instructions.cc @@ -1283,7 +1283,6 @@ namespace { String* TypeOfString(HConstant* constant, Isolate* isolate) { Heap* heap = isolate->heap(); if (constant->HasNumberValue()) return heap->number_string(); - if (constant->IsUndetectable()) return heap->undefined_string(); if (constant->HasStringValue()) return heap->string_string(); switch (constant->GetInstanceType()) { case ODDBALL_TYPE: { @@ -1312,6 +1311,7 @@ String* TypeOfString(HConstant* constant, Isolate* isolate) { return nullptr; } default: + if (constant->IsUndetectable()) return heap->undefined_string(); if (constant->IsCallable()) return heap->function_string(); return heap->object_string(); } diff --git a/deps/v8/test/mjsunit/regress/regress-opt-typeof-null.js b/deps/v8/test/mjsunit/regress/regress-opt-typeof-null.js new file mode 100644 index 00000000000000..e4721a18c5e0fb --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-opt-typeof-null.js @@ -0,0 +1,12 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function f() { + return typeof null === "object"; +}; + +%OptimizeFunctionOnNextCall(f); +assertTrue(f());