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

Side by Side Diff: runtime/vm/kernel_to_il.cc

Issue 2624513005: Small cleanups in the Kernel FlowGraphBuilder (Closed)
Patch Set: Incorporate review comments Created 3 years, 11 months 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/kernel_to_il.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <map> 5 #include <map>
6 #include <set> 6 #include <set>
7 #include <string> 7 #include <string>
8 8
9 #include "vm/kernel_to_il.h" 9 #include "vm/kernel_to_il.h"
10 10
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 // instructions do not make a copy of the handle, so we do it. 1312 // instructions do not make a copy of the handle, so we do it.
1313 return dart::Instance::ZoneHandle(Z, result_.raw()); 1313 return dart::Instance::ZoneHandle(Z, result_.raw());
1314 } 1314 }
1315 1315
1316 1316
1317 Object& ConstantEvaluator::EvaluateExpressionSafe(Expression* expression) { 1317 Object& ConstantEvaluator::EvaluateExpressionSafe(Expression* expression) {
1318 LongJumpScope jump; 1318 LongJumpScope jump;
1319 if (setjmp(*jump.Set()) == 0) { 1319 if (setjmp(*jump.Set()) == 0) {
1320 return EvaluateExpression(expression); 1320 return EvaluateExpression(expression);
1321 } else { 1321 } else {
1322 Thread* thread = Thread::Current(); 1322 Thread* thread = H.thread();
1323 Error& error = Error::Handle(Z); 1323 Error& error = Error::Handle(Z);
1324 error = thread->sticky_error(); 1324 error = thread->sticky_error();
1325 thread->clear_sticky_error(); 1325 thread->clear_sticky_error();
1326 return error; 1326 return error;
1327 } 1327 }
1328 } 1328 }
1329 1329
1330 1330
1331 Instance& ConstantEvaluator::EvaluateConstructorInvocation( 1331 Instance& ConstantEvaluator::EvaluateConstructorInvocation(
1332 ConstructorInvocation* node) { 1332 ConstructorInvocation* node) {
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 } 1843 }
1844 1844
1845 1845
1846 FlowGraphBuilder::FlowGraphBuilder( 1846 FlowGraphBuilder::FlowGraphBuilder(
1847 TreeNode* node, 1847 TreeNode* node,
1848 ParsedFunction* parsed_function, 1848 ParsedFunction* parsed_function,
1849 const ZoneGrowableArray<const ICData*>& ic_data_array, 1849 const ZoneGrowableArray<const ICData*>& ic_data_array,
1850 InlineExitCollector* exit_collector, 1850 InlineExitCollector* exit_collector,
1851 intptr_t osr_id, 1851 intptr_t osr_id,
1852 intptr_t first_block_id) 1852 intptr_t first_block_id)
1853 : zone_(Thread::Current()->zone()), 1853 : translation_helper_(Thread::Current()),
1854 translation_helper_(Thread::Current(), 1854 zone_(translation_helper_.zone()),
1855 zone_,
1856 Thread::Current()->isolate()),
1857 node_(node), 1855 node_(node),
1858 parsed_function_(parsed_function), 1856 parsed_function_(parsed_function),
1859 osr_id_(osr_id), 1857 osr_id_(osr_id),
1860 ic_data_array_(ic_data_array), 1858 ic_data_array_(ic_data_array),
1861 exit_collector_(exit_collector), 1859 exit_collector_(exit_collector),
1862 next_block_id_(first_block_id), 1860 next_block_id_(first_block_id),
1863 next_function_id_(0), 1861 next_function_id_(0),
1864 context_depth_(0), 1862 context_depth_(0),
1865 loop_depth_(0), 1863 loop_depth_(0),
1866 try_depth_(0), 1864 try_depth_(0),
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
2185 2183
2186 Fragment FlowGraphBuilder::CatchBlockEntry(const Array& handler_types, 2184 Fragment FlowGraphBuilder::CatchBlockEntry(const Array& handler_types,
2187 intptr_t handler_index) { 2185 intptr_t handler_index) {
2188 ASSERT(CurrentException()->is_captured() == 2186 ASSERT(CurrentException()->is_captured() ==
2189 CurrentStackTrace()->is_captured()); 2187 CurrentStackTrace()->is_captured());
2190 const bool should_restore_closure_context = 2188 const bool should_restore_closure_context =
2191 CurrentException()->is_captured() || CurrentCatchContext()->is_captured(); 2189 CurrentException()->is_captured() || CurrentCatchContext()->is_captured();
2192 CatchBlockEntryInstr* entry = new (Z) CatchBlockEntryInstr( 2190 CatchBlockEntryInstr* entry = new (Z) CatchBlockEntryInstr(
2193 AllocateBlockId(), CurrentTryIndex(), graph_entry_, handler_types, 2191 AllocateBlockId(), CurrentTryIndex(), graph_entry_, handler_types,
2194 handler_index, *CurrentException(), *CurrentStackTrace(), 2192 handler_index, *CurrentException(), *CurrentStackTrace(),
2195 /* needs_stacktrace = */ true, Thread::Current()->GetNextDeoptId(), 2193 /* needs_stacktrace = */ true, H.thread()->GetNextDeoptId(),
2196 should_restore_closure_context); 2194 should_restore_closure_context);
2197 graph_entry_->AddCatchEntry(entry); 2195 graph_entry_->AddCatchEntry(entry);
2198 Fragment instructions(entry); 2196 Fragment instructions(entry);
2199 2197
2200 // :saved_try_context_var can be captured in the context of 2198 // :saved_try_context_var can be captured in the context of
2201 // of the closure, in this case CatchBlockEntryInstr restores 2199 // of the closure, in this case CatchBlockEntryInstr restores
2202 // :current_context_var to point to closure context in the 2200 // :current_context_var to point to closure context in the
2203 // same way as normal function prologue does. 2201 // same way as normal function prologue does.
2204 // Update current context depth to reflect that. 2202 // Update current context depth to reflect that.
2205 const intptr_t saved_context_depth = context_depth_; 2203 const intptr_t saved_context_depth = context_depth_;
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
2555 return Fragment(store); 2553 return Fragment(store);
2556 } 2554 }
2557 2555
2558 2556
2559 Fragment FlowGraphBuilder::StoreInstanceFieldGuarded(const dart::Field& field) { 2557 Fragment FlowGraphBuilder::StoreInstanceFieldGuarded(const dart::Field& field) {
2560 Fragment instructions; 2558 Fragment instructions;
2561 const dart::Field& field_clone = MayCloneField(Z, field); 2559 const dart::Field& field_clone = MayCloneField(Z, field);
2562 if (FLAG_use_field_guards) { 2560 if (FLAG_use_field_guards) {
2563 LocalVariable* store_expression = MakeTemporary(); 2561 LocalVariable* store_expression = MakeTemporary();
2564 instructions += LoadLocal(store_expression); 2562 instructions += LoadLocal(store_expression);
2565 instructions += 2563 instructions += GuardFieldClass(field_clone, H.thread()->GetNextDeoptId());
2566 GuardFieldClass(field_clone, Thread::Current()->GetNextDeoptId());
2567 instructions += LoadLocal(store_expression); 2564 instructions += LoadLocal(store_expression);
2568 instructions += 2565 instructions += GuardFieldLength(field_clone, H.thread()->GetNextDeoptId());
2569 GuardFieldLength(field_clone, Thread::Current()->GetNextDeoptId());
2570 } 2566 }
2571 instructions += StoreInstanceField(field_clone); 2567 instructions += StoreInstanceField(field_clone);
2572 return instructions; 2568 return instructions;
2573 } 2569 }
2574 2570
2575 2571
2576 Fragment FlowGraphBuilder::StoreInstanceField( 2572 Fragment FlowGraphBuilder::StoreInstanceField(
2577 intptr_t offset, 2573 intptr_t offset,
2578 StoreBarrierType emit_store_barrier) { 2574 StoreBarrierType emit_store_barrier) {
2579 Value* value = Pop(); 2575 Value* value = Pop();
(...skipping 2324 matching lines...) Expand 10 before | Expand all | Expand 10 after
4904 instructions += LoadLocal(catch_block_->exception_var()); 4900 instructions += LoadLocal(catch_block_->exception_var());
4905 instructions += PushArgument(); 4901 instructions += PushArgument();
4906 instructions += LoadLocal(catch_block_->stack_trace_var()); 4902 instructions += LoadLocal(catch_block_->stack_trace_var());
4907 instructions += PushArgument(); 4903 instructions += PushArgument();
4908 instructions += RethrowException(catch_block_->catch_try_index()); 4904 instructions += RethrowException(catch_block_->catch_try_index());
4909 4905
4910 fragment_ = instructions; 4906 fragment_ = instructions;
4911 } 4907 }
4912 4908
4913 4909
4914 void FlowGraphBuilder::VisitBlockExpression(BlockExpression* node) {
4915 Fragment instructions = TranslateStatement(node->body());
4916 instructions += TranslateExpression(node->value());
4917 fragment_ = instructions;
4918 }
4919
4920
4921 Fragment FlowGraphBuilder::TranslateArguments(Arguments* node, 4910 Fragment FlowGraphBuilder::TranslateArguments(Arguments* node,
4922 Array* argument_names) { 4911 Array* argument_names) {
4923 Fragment instructions; 4912 Fragment instructions;
4924 4913
4925 List<Expression>& positional = node->positional(); 4914 List<Expression>& positional = node->positional();
4926 for (intptr_t i = 0; i < positional.length(); ++i) { 4915 for (intptr_t i = 0; i < positional.length(); ++i) {
4927 instructions += TranslateExpression(positional[i]); 4916 instructions += TranslateExpression(positional[i]);
4928 instructions += PushArgument(); 4917 instructions += PushArgument();
4929 } 4918 }
4930 4919
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
5847 instructions += LoadLocal(parsed_function_->current_context_var()); 5836 instructions += LoadLocal(parsed_function_->current_context_var());
5848 instructions += StoreInstanceField(Closure::context_offset()); 5837 instructions += StoreInstanceField(Closure::context_offset());
5849 5838
5850 return instructions; 5839 return instructions;
5851 } 5840 }
5852 5841
5853 5842
5854 } // namespace kernel 5843 } // namespace kernel
5855 } // namespace dart 5844 } // namespace dart
5856 #endif // !defined(DART_PRECOMPILED_RUNTIME) 5845 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW
« no previous file with comments | « runtime/vm/kernel_to_il.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698