Commit 5945f9eb authored by bmeurer@chromium.org's avatar bmeurer@chromium.org

Fix handling of constant global variable assignments.

BUG=347904
LOG=y
R=hpayer@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19594 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0a931631
......@@ -5909,12 +5909,20 @@ void HOptimizedGraphBuilder::HandleGlobalVariableAssignment(
Handle<GlobalObject> global(current_info()->global_object());
Handle<PropertyCell> cell(global->GetPropertyCell(&lookup));
if (cell->type()->IsConstant()) {
Handle<Object> constant = cell->type()->AsConstant();
if (value->IsConstant()) {
HConstant* c_value = HConstant::cast(value);
if (!constant.is_identical_to(c_value->handle(isolate()))) {
Add<HDeoptimize>("Constant global variable assignment",
Deoptimizer::EAGER);
}
} else {
HValue* c_constant = Add<HConstant>(constant);
IfBuilder builder(this);
HValue* constant = Add<HConstant>(cell->type()->AsConstant());
if (cell->type()->AsConstant()->IsNumber()) {
builder.If<HCompareNumericAndBranch>(value, constant, Token::EQ);
if (constant->IsNumber()) {
builder.If<HCompareNumericAndBranch>(value, c_constant, Token::EQ);
} else {
builder.If<HCompareObjectEqAndBranch>(value, constant);
builder.If<HCompareObjectEqAndBranch>(value, c_constant);
}
builder.Then();
builder.Else();
......@@ -5922,6 +5930,7 @@ void HOptimizedGraphBuilder::HandleGlobalVariableAssignment(
Deoptimizer::EAGER);
builder.End();
}
}
HInstruction* instr =
Add<HStoreGlobalCell>(value, cell, lookup.GetPropertyDetails());
if (instr->HasObservableSideEffects()) {
......
// Copyright 2014 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 --stress-runs=2
var v = /abc/;
function f() {
v = 1578221999;
};
%OptimizeFunctionOnNextCall(f);
f();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment