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

Side by Side Diff: runtime/vm/code_generator_ia32.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 | « no previous file | runtime/vm/code_generator_x64.cc » ('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/globals.h" // Needed here to get TARGET_ARCH_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/code_generator.h" 8 #include "vm/code_generator.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 const Immediate raw_null = 160 const Immediate raw_null =
161 Immediate(reinterpret_cast<intptr_t>(Object::null())); 161 Immediate(reinterpret_cast<intptr_t>(Object::null()));
162 __ movl(EAX, raw_null); 162 __ movl(EAX, raw_null);
163 __ ret(); 163 __ ret();
164 } 164 }
165 165
166 166
167 167
168 bool CodeGenerator::TryIntrinsify() { 168 bool CodeGenerator::TryIntrinsify() {
169 if (!CanOptimize()) return false; 169 if (!CanOptimize()) return false;
170 if (FLAG_intrinsify && !FLAG_trace_functions) { 170 // Intrinsification skips arguments checks, therefore disable if in checked
171 // mode.
172 if (FLAG_intrinsify && !FLAG_trace_functions && !FLAG_enable_type_checks) {
171 if ((parsed_function_.function().kind() == RawFunction::kImplicitGetter)) { 173 if ((parsed_function_.function().kind() == RawFunction::kImplicitGetter)) {
172 IntrinsifyGetter(); 174 IntrinsifyGetter();
173 return true; 175 return true;
174 } 176 }
175 // Intrinsification skips arguments checks, therefore disable if in checked 177 if ((parsed_function_.function().kind() == RawFunction::kImplicitSetter)) {
176 // mode.
177 if ((parsed_function_.function().kind() == RawFunction::kImplicitSetter) &&
178 !FLAG_enable_type_checks) {
179 IntrinsifySetter(); 178 IntrinsifySetter();
180 return true; 179 return true;
181 } 180 }
182 } 181 }
183 // Even if an intrinsified version of the function was successfully 182 // Even if an intrinsified version of the function was successfully
184 // generated, it may fall through to the non-intrinsified method body. 183 // generated, it may fall through to the non-intrinsified method body.
185 if (!FLAG_trace_functions) { 184 if (!FLAG_trace_functions) {
186 return Intrinsifier::Intrinsify(parsed_function().function(), assembler_); 185 return Intrinsifier::Intrinsify(parsed_function().function(), assembler_);
187 } 186 }
188 return false; 187 return false;
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 } else { 767 } else {
769 // Pop the previously evaluated result value into EAX. 768 // Pop the previously evaluated result value into EAX.
770 __ popl(EAX); 769 __ popl(EAX);
771 } 770 }
772 771
773 // Generate type check. 772 // Generate type check.
774 if (FLAG_enable_type_checks) { 773 if (FLAG_enable_type_checks) {
775 const bool returns_null = node->value()->IsLiteralNode() && 774 const bool returns_null = node->value()->IsLiteralNode() &&
776 node->value()->AsLiteralNode()->literal().IsNull(); 775 node->value()->AsLiteralNode()->literal().IsNull();
777 const RawFunction::Kind kind = parsed_function().function().kind(); 776 const RawFunction::Kind kind = parsed_function().function().kind();
778 // Implicit getters do not need a type check at return. 777 const bool is_implicit_getter =
779 if (!returns_null && 778 (kind == RawFunction::kImplicitGetter) ||
780 (kind != RawFunction::kImplicitGetter) && 779 (kind == RawFunction::kConstImplicitGetter);
781 (kind != RawFunction::kConstImplicitGetter)) { 780 const bool is_static = parsed_function().function().is_static();
781 // Implicit getters do not need a type check at return, unless they compute
782 // the initial value of a static field.
783 if (!returns_null && (is_static || !is_implicit_getter)) {
782 GenerateAssertAssignable( 784 GenerateAssertAssignable(
783 node->id(), 785 node->id(),
784 node->value()->token_index(), 786 node->value()->token_index(),
785 AbstractType::ZoneHandle(parsed_function().function().result_type()), 787 AbstractType::ZoneHandle(parsed_function().function().result_type()),
786 String::ZoneHandle(String::NewSymbol("function result"))); 788 String::ZoneHandle(String::NewSymbol("function result")));
787 } 789 }
788 } 790 }
789 GenerateReturnEpilog(node); 791 GenerateReturnEpilog(node);
790 } 792 }
791 793
(...skipping 2047 matching lines...) Expand 10 before | Expand all | Expand 10 after
2839 const Error& error = Error::Handle( 2841 const Error& error = Error::Handle(
2840 Parser::FormatError(script, token_index, "Error", format, args)); 2842 Parser::FormatError(script, token_index, "Error", format, args));
2841 va_end(args); 2843 va_end(args);
2842 Isolate::Current()->long_jump_base()->Jump(1, error); 2844 Isolate::Current()->long_jump_base()->Jump(1, error);
2843 UNREACHABLE(); 2845 UNREACHABLE();
2844 } 2846 }
2845 2847
2846 } // namespace dart 2848 } // namespace dart
2847 2849
2848 #endif // defined TARGET_ARCH_IA32 2850 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/code_generator_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698