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

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

Issue 9958091: Add missing type checks for top level static initializers (issue 1980 and (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/code_generator_x64.cc ('k') | runtime/vm/parser.h » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "vm/flow_graph_builder.h" 5 #include "vm/flow_graph_builder.h"
6 6
7 #include "vm/ast_printer.h" 7 #include "vm/ast_printer.h"
8 #include "vm/flags.h" 8 #include "vm/flags.h"
9 #include "vm/intermediate_language.h" 9 #include "vm/intermediate_language.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 for (intptr_t i = 0; i < node->inlined_finally_list_length(); i++) { 147 for (intptr_t i = 0; i < node->inlined_finally_list_length(); i++) {
148 EffectGraphVisitor for_effect(owner(), for_value.temp_index()); 148 EffectGraphVisitor for_effect(owner(), for_value.temp_index());
149 node->InlinedFinallyNodeAt(i)->Visit(&for_effect); 149 node->InlinedFinallyNodeAt(i)->Visit(&for_effect);
150 Append(for_effect); 150 Append(for_effect);
151 if (!is_open()) return; 151 if (!is_open()) return;
152 } 152 }
153 153
154 Value* return_value = for_value.value(); 154 Value* return_value = for_value.value();
155 if (FLAG_enable_type_checks) { 155 if (FLAG_enable_type_checks) {
156 const RawFunction::Kind kind = owner()->parsed_function().function().kind(); 156 const RawFunction::Kind kind = owner()->parsed_function().function().kind();
157 // Implicit getters do not need a type check at return. 157 const bool is_implicit_getter =
158 if ((kind != RawFunction::kImplicitGetter) && 158 (kind == RawFunction::kImplicitGetter) ||
159 (kind != RawFunction::kConstImplicitGetter)) { 159 (kind == RawFunction::kConstImplicitGetter);
160 const bool is_static = owner()->parsed_function().function().is_static();
161 // Implicit getters do not need a type check at return, unless they compute
162 // the initial value of a static field.
163 if (is_static || !is_implicit_getter) {
160 const AbstractType& type = 164 const AbstractType& type =
161 AbstractType::ZoneHandle( 165 AbstractType::ZoneHandle(
162 owner()->parsed_function().function().result_type()); 166 owner()->parsed_function().function().result_type());
163 AssertAssignableComp* assert = 167 AssertAssignableComp* assert =
164 new AssertAssignableComp(return_value, type); 168 new AssertAssignableComp(return_value, type);
165 AddInstruction(new BindInstr(temp_index(), assert)); 169 AddInstruction(new BindInstr(temp_index(), assert));
166 return_value = new TempVal(temp_index()); 170 return_value = new TempVal(temp_index());
167 } 171 }
168 } 172 }
169 173
(...skipping 1939 matching lines...) Expand 10 before | Expand all | Expand 10 after
2109 char* chars = reinterpret_cast<char*>( 2113 char* chars = reinterpret_cast<char*>(
2110 Isolate::Current()->current_zone()->Allocate(len)); 2114 Isolate::Current()->current_zone()->Allocate(len));
2111 OS::SNPrint(chars, len, kFormat, function_name, reason); 2115 OS::SNPrint(chars, len, kFormat, function_name, reason);
2112 const Error& error = Error::Handle( 2116 const Error& error = Error::Handle(
2113 LanguageError::New(String::Handle(String::New(chars)))); 2117 LanguageError::New(String::Handle(String::New(chars))));
2114 Isolate::Current()->long_jump_base()->Jump(1, error); 2118 Isolate::Current()->long_jump_base()->Jump(1, error);
2115 } 2119 }
2116 2120
2117 2121
2118 } // namespace dart 2122 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_generator_x64.cc ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698