Skip to content

Commit

Permalink
deps: backport 7dfb5beeec from V8 upstream
Browse files Browse the repository at this point in the history
This commit backports a fix to a JIT bug in V8.
After 100 or so comparisons `typeof null ==="undefined"` is returning
`true` instead of `false`.

Original commit message:

	Fix 'typeof null' canonicalization in crankshaft

	BUG=

	Review URL: https://codereview.chromium.org/1912553002

	Cr-Commit-Position: refs/heads/master@{#35699}

Ref: https://bugs.chromium.org/p/chromium/issues/detail?id=604033
PR-URL: #7348
Reviewed-By: Ali Ijaz Sheikh <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
  • Loading branch information
MylesBorins authored and Myles Borins committed Jun 22, 2016
1 parent 1e7a7be commit c544213
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion deps/v8/src/crankshaft/hydrogen-instructions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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();
}
Expand Down
12 changes: 12 additions & 0 deletions deps/v8/test/mjsunit/regress/regress-opt-typeof-null.js
Original file line number Diff line number Diff line change
@@ -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());

0 comments on commit c544213

Please sign in to comment.