Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(795)

Unified Diff: runtime/vm/kernel_to_il.cc

Issue 2469703002: Implement instance field guards for kernel-based FlowGraphBuilder (Closed)
Patch Set: update status file Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/kernel_to_il.h ('k') | tests/language/language_kernel.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/kernel_to_il.cc
diff --git a/runtime/vm/kernel_to_il.cc b/runtime/vm/kernel_to_il.cc
index e5bf5ae5da44bbd5bbf1464de139639857d4cffe..04d93afdec29f81c2069ff25240bafdc66fa4c3a 100644
--- a/runtime/vm/kernel_to_il.cc
+++ b/runtime/vm/kernel_to_il.cc
@@ -2368,6 +2368,21 @@ Fragment FlowGraphBuilder::StoreInstanceField(const dart::Field& field) {
}
+Fragment FlowGraphBuilder::StoreInstanceFieldGuarded(const dart::Field& field) {
+ Fragment instructions;
+ if (FLAG_use_field_guards) {
+ LocalVariable* store_expression = MakeTemporary();
+ instructions += LoadLocal(store_expression);
+ instructions += GuardFieldClass(field, Thread::Current()->GetNextDeoptId());
+ instructions += LoadLocal(store_expression);
+ instructions +=
+ GuardFieldLength(field, Thread::Current()->GetNextDeoptId());
+ }
+ instructions += StoreInstanceField(field);
+ return instructions;
+}
+
+
Fragment FlowGraphBuilder::StoreInstanceField(intptr_t offset) {
Value* value = Pop();
StoreInstanceFieldInstr* store = new (Z) StoreInstanceFieldInstr(
@@ -3099,13 +3114,12 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfFieldAccessor(
graph_entry_ = new (Z)
GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId);
- // TODO(27590): Add support for FLAG_use_field_guards.
Fragment body(normal_entry);
if (is_setter) {
if (is_method) {
body += LoadLocal(scopes_->this_variable);
body += LoadLocal(setter_value);
- body += StoreInstanceField(field);
+ body += StoreInstanceFieldGuarded(field);
} else {
body += LoadLocal(setter_value);
body += StoreStaticField(field);
@@ -3193,6 +3207,18 @@ Fragment FlowGraphBuilder::BuildImplicitClosureCreation(
}
+Fragment FlowGraphBuilder::GuardFieldLength(const dart::Field& field,
+ intptr_t deopt_id) {
+ return Fragment(new (Z) GuardFieldLengthInstr(Pop(), field, deopt_id));
+}
+
+
+Fragment FlowGraphBuilder::GuardFieldClass(const dart::Field& field,
+ intptr_t deopt_id) {
+ return Fragment(new (Z) GuardFieldClassInstr(Pop(), field, deopt_id));
+}
+
+
FlowGraph* FlowGraphBuilder::BuildGraphOfMethodExtractor(
const Function& method) {
// A method extractor is the implicit getter for a method.
@@ -3515,10 +3541,9 @@ Fragment FlowGraphBuilder::TranslateInitializers(
dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(kernel_field));
EnterScope(kernel_field);
- // TODO(27590): Support FLAG_use_field_guards.
instructions += LoadLocal(scopes_->this_variable);
instructions += TranslateExpression(init);
- instructions += StoreInstanceField(field);
+ instructions += StoreInstanceFieldGuarded(field);
ExitScope(kernel_field);
}
}
@@ -3536,10 +3561,9 @@ Fragment FlowGraphBuilder::TranslateInitializers(
dart::Field& field =
dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(init->field()));
- // TODO(27590): Support FLAG_use_field_guards.
instructions += LoadLocal(scopes_->this_variable);
instructions += TranslateExpression(init->value());
- instructions += StoreInstanceField(field);
+ instructions += StoreInstanceFieldGuarded(field);
} else if (initializer->IsSuperInitializer()) {
SuperInitializer* init = SuperInitializer::Cast(initializer);
« no previous file with comments | « runtime/vm/kernel_to_il.h ('k') | tests/language/language_kernel.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698