Commit 0f7ea219 authored by franzih's avatar franzih Committed by Commit bot

[compiler] Delete extra map check.

Use HeapConstant for string_iterator_map rather than loading it
manually. This avoids unnecessary map checks.

BUG= v8:3822,v8:5267

Review-Url: https://codereview.chromium.org/2479563003
Cr-Commit-Position: refs/heads/master@{#40741}
parent cdf9a406
......@@ -96,11 +96,13 @@ class JSCallReduction {
JSBuiltinReducer::JSBuiltinReducer(Editor* editor, JSGraph* jsgraph,
Flags flags,
CompilationDependencies* dependencies)
CompilationDependencies* dependencies,
Handle<Context> native_context)
: AdvancedReducer(editor),
dependencies_(dependencies),
flags_(flags),
jsgraph_(jsgraph),
native_context_(native_context),
type_cache_(TypeCache::Get()) {}
namespace {
......@@ -1033,14 +1035,9 @@ Reduction JSBuiltinReducer::ReduceStringIterator(Node* node) {
if (Node* receiver = GetStringWitness(node)) {
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
Node* context = NodeProperties::GetContextInput(node);
Node* native_context = effect = graph()->NewNode(
javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true),
context, context, effect);
Node* map = effect = graph()->NewNode(
javascript()->LoadContext(0, Context::STRING_ITERATOR_MAP_INDEX, true),
native_context, native_context, effect);
Node* map = jsgraph()->HeapConstant(
handle(native_context()->string_iterator_map(), isolate()));
// allocate new iterator
effect = graph()->NewNode(
......
......@@ -38,7 +38,8 @@ class V8_EXPORT_PRIVATE JSBuiltinReducer final
typedef base::Flags<Flag> Flags;
JSBuiltinReducer(Editor* editor, JSGraph* jsgraph, Flags flags,
CompilationDependencies* dependencies);
CompilationDependencies* dependencies,
Handle<Context> native_context);
~JSBuiltinReducer() final {}
Reduction Reduce(Node* node) final;
......@@ -104,6 +105,7 @@ class V8_EXPORT_PRIVATE JSBuiltinReducer final
Factory* factory() const;
JSGraph* jsgraph() const { return jsgraph_; }
Isolate* isolate() const;
Handle<Context> native_context() const { return native_context_; }
CommonOperatorBuilder* common() const;
SimplifiedOperatorBuilder* simplified() const;
JSOperatorBuilder* javascript() const;
......@@ -112,6 +114,7 @@ class V8_EXPORT_PRIVATE JSBuiltinReducer final
CompilationDependencies* const dependencies_;
Flags const flags_;
JSGraph* const jsgraph_;
Handle<Context> const native_context_;
TypeCache const& type_cache_;
};
......
......@@ -918,7 +918,7 @@ struct TypedLoweringPhase {
data->info()->is_deoptimization_enabled()
? JSBuiltinReducer::kDeoptimizationEnabled
: JSBuiltinReducer::kNoFlags,
data->info()->dependencies());
data->info()->dependencies(), data->native_context());
Handle<LiteralsArray> literals_array(data->info()->closure()->literals());
JSCreateLowering create_lowering(
&graph_reducer, data->info()->dependencies(), data->jsgraph(),
......
......@@ -33,8 +33,10 @@ class JSBuiltinReducerTest : public TypedGraphTest {
&machine);
// TODO(titzer): mock the GraphReducer here for better unit testing.
GraphReducer graph_reducer(zone(), graph());
JSBuiltinReducer reducer(&graph_reducer, &jsgraph,
JSBuiltinReducer::kNoFlags, nullptr);
JSBuiltinReducer::kNoFlags, nullptr,
native_context());
return reducer.Reduce(node);
}
......
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