Commit d8e14775 authored by jgruber's avatar jgruber Committed by Commit Bot

[regexp] Teach deoptimizer to materialize JSRegExp objects

Now that literal allocation is inlined, it is possible to optimize out regexp
literal allocation completely. If a lazy deopt is triggered in that situation,
the deoptimizer needs to know how to materialize regexp objects.

Bug: v8:6605,v8:6556,chromium:747825
Change-Id: Id491053f8e64fec16540efbfdc6c7c524da3e080
Reviewed-on: https://chromium-review.googlesource.com/582609Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46837}
parent d70be3fa
......@@ -3835,6 +3835,24 @@ Handle<Object> TranslatedState::MaterializeCapturedObjectAt(
}
return object;
}
case JS_REGEXP_TYPE: {
Handle<JSRegExp> object = Handle<JSRegExp>::cast(
isolate_->factory()->NewJSObjectFromMap(map, NOT_TENURED));
slot->value_ = object;
Handle<Object> properties = materializer.FieldAt(value_index);
Handle<Object> elements = materializer.FieldAt(value_index);
Handle<Object> data = materializer.FieldAt(value_index);
Handle<Object> source = materializer.FieldAt(value_index);
Handle<Object> flags = materializer.FieldAt(value_index);
Handle<Object> last_index = materializer.FieldAt(value_index);
object->set_raw_properties_or_hash(*properties);
object->set_elements(FixedArrayBase::cast(*elements));
object->set_data(*data);
object->set_source(*source);
object->set_flags(*flags);
object->set_last_index(*last_index);
return object;
}
case STRING_TYPE:
case ONE_BYTE_STRING_TYPE:
case CONS_ONE_BYTE_STRING_TYPE:
......@@ -3870,7 +3888,6 @@ Handle<Object> TranslatedState::MaterializeCapturedObjectAt(
case JS_ASYNC_GENERATOR_OBJECT_TYPE:
case JS_MODULE_NAMESPACE_TYPE:
case JS_ARRAY_BUFFER_TYPE:
case JS_REGEXP_TYPE:
case JS_TYPED_ARRAY_TYPE:
case JS_DATA_VIEW_TYPE:
case JS_SET_TYPE:
......
// Copyright 2017 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
var g = 0;
g = function() {}
function f() {
var r = /[abc]/i; // Optimized out.
g(r);
}
f(); f(); %OptimizeFunctionOnNextCall(f); // Warm-up.
var re;
g = function(r) { re = r; }
f(); // Lazy deopt is forced here.
assertNotEquals(undefined, re);
assertEquals("[abc]", re.source);
assertEquals("i", re.flags);
assertEquals(0, re.lastIndex);
assertArrayEquals(["a"], re.exec("a"));
assertArrayEquals(["A"], re.exec("A"));
assertNull(re.exec("d"));
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