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

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

Issue 340203003: Cleanup of error and warning reporting. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/code_generator.h" 5 #include "vm/code_generator.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/ast.h" 8 #include "vm/ast.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
11 #include "vm/compiler.h" 11 #include "vm/compiler.h"
12 #include "vm/dart_api_impl.h" 12 #include "vm/dart_api_impl.h"
13 #include "vm/dart_entry.h" 13 #include "vm/dart_entry.h"
14 #include "vm/debugger.h" 14 #include "vm/debugger.h"
15 #include "vm/deopt_instructions.h" 15 #include "vm/deopt_instructions.h"
16 #include "vm/exceptions.h" 16 #include "vm/exceptions.h"
17 #include "vm/intermediate_language.h" 17 #include "vm/intermediate_language.h"
18 #include "vm/object_store.h" 18 #include "vm/object_store.h"
19 #include "vm/message.h" 19 #include "vm/message.h"
20 #include "vm/message_handler.h" 20 #include "vm/message_handler.h"
21 #include "vm/parser.h" 21 #include "vm/parser.h"
22 #include "vm/report.h"
22 #include "vm/resolver.h" 23 #include "vm/resolver.h"
23 #include "vm/runtime_entry.h" 24 #include "vm/runtime_entry.h"
24 #include "vm/stack_frame.h" 25 #include "vm/stack_frame.h"
25 #include "vm/symbols.h" 26 #include "vm/symbols.h"
26 #include "vm/verifier.h" 27 #include "vm/verifier.h"
27 28
28 namespace dart { 29 namespace dart {
29 30
30 DEFINE_FLAG(bool, deoptimize_alot, false, 31 DEFINE_FLAG(bool, deoptimize_alot, false,
31 "Deoptimizes all live frames when we are about to return to Dart code from" 32 "Deoptimizes all live frames when we are about to return to Dart code from"
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 const Instance& src_value = Instance::CheckedHandle(arguments.ArgAt(0)); 568 const Instance& src_value = Instance::CheckedHandle(arguments.ArgAt(0));
568 const String& dst_name = String::CheckedHandle(arguments.ArgAt(1)); 569 const String& dst_name = String::CheckedHandle(arguments.ArgAt(1));
569 const AbstractType& dst_type = 570 const AbstractType& dst_type =
570 AbstractType::CheckedHandle(arguments.ArgAt(2)); 571 AbstractType::CheckedHandle(arguments.ArgAt(2));
571 const AbstractType& src_type = AbstractType::Handle(src_value.GetType()); 572 const AbstractType& src_type = AbstractType::Handle(src_value.GetType());
572 const String& src_type_name = String::Handle(src_type.UserVisibleName()); 573 const String& src_type_name = String::Handle(src_type.UserVisibleName());
573 574
574 String& dst_type_name = String::Handle(); 575 String& dst_type_name = String::Handle();
575 LanguageError& error = LanguageError::Handle(dst_type.error()); 576 LanguageError& error = LanguageError::Handle(dst_type.error());
576 ASSERT(!error.IsNull()); 577 ASSERT(!error.IsNull());
577 if (error.kind() == LanguageError::kMalformedType) { 578 if (error.kind() == Report::kMalformedType) {
578 dst_type_name = Symbols::Malformed().raw(); 579 dst_type_name = Symbols::Malformed().raw();
579 } else { 580 } else {
580 ASSERT(error.kind() == LanguageError::kMalboundedType); 581 ASSERT(error.kind() == Report::kMalboundedType);
581 dst_type_name = Symbols::Malbounded().raw(); 582 dst_type_name = Symbols::Malbounded().raw();
582 } 583 }
583 const String& error_message = String::ZoneHandle( 584 const String& error_message = String::ZoneHandle(
584 Symbols::New(error.ToErrorCString())); 585 Symbols::New(error.ToErrorCString()));
585 Exceptions::CreateAndThrowTypeError( 586 Exceptions::CreateAndThrowTypeError(
586 location, src_type_name, dst_type_name, dst_name, error_message); 587 location, src_type_name, dst_type_name, dst_name, error_message);
587 UNREACHABLE(); 588 UNREACHABLE();
588 } 589 }
589 590
590 591
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 caller_frame->pc(), 800 caller_frame->pc(),
800 Class::Handle(receiver.clazz()).ToCString(), 801 Class::Handle(receiver.clazz()).ToCString(),
801 receiver.GetClassId(), 802 receiver.GetClassId(),
802 target_function.ToCString()); 803 target_function.ToCString());
803 } 804 }
804 } 805 }
805 return target_function.raw(); 806 return target_function.raw();
806 } 807 }
807 808
808 809
809 static void JSWarning(const ICData& ic_data, const char* msg) {
810 DartFrameIterator iterator;
811 StackFrame* caller_frame = iterator.NextFrame();
812 ASSERT(caller_frame != NULL);
813 // Report warning only if not already reported at this location.
814 if (!ic_data.IssuedJSWarning()) {
815 ic_data.SetIssuedJSWarning();
816 Exceptions::JSWarning(caller_frame, "%s", msg);
817 }
818 }
819
820
821 // Handles inline cache misses by updating the IC data array of the call site. 810 // Handles inline cache misses by updating the IC data array of the call site.
822 // Arg0: Receiver object. 811 // Arg0: Receiver object.
823 // Arg1: IC data object. 812 // Arg1: IC data object.
824 // Returns: target function with compiled code or null. 813 // Returns: target function with compiled code or null.
825 // Modifies the instance call to hold the updated IC data array. 814 // Modifies the instance call to hold the updated IC data array.
826 DEFINE_RUNTIME_ENTRY(InlineCacheMissHandlerOneArg, 2) { 815 DEFINE_RUNTIME_ENTRY(InlineCacheMissHandlerOneArg, 2) {
827 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0)); 816 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0));
828 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(1)); 817 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(1));
829 GrowableArray<const Instance*> args(1); 818 GrowableArray<const Instance*> args(1);
830 args.Add(&receiver); 819 args.Add(&receiver);
831 if (FLAG_warn_on_javascript_compatibility) { 820 if (FLAG_warn_on_javascript_compatibility) {
832 if (receiver.IsDouble() && 821 if (receiver.IsDouble() &&
833 String::Handle(ic_data.target_name()).Equals(Symbols::toString())) { 822 String::Handle(ic_data.target_name()).Equals(Symbols::toString())) {
834 const double value = Double::Cast(receiver).value(); 823 const double value = Double::Cast(receiver).value();
835 if (floor(value) == value) { 824 if (floor(value) == value) {
836 JSWarning(ic_data, 825 Report::JSWarningFromIC(ic_data,
837 "string representation of an integral value of type " 826 "string representation of an integral value "
838 "'double' has no decimal mark and no fractional part"); 827 "of type 'double' has no decimal mark and "
828 "no fractional part");
839 } 829 }
840 } 830 }
841 } 831 }
842 const Function& result = 832 const Function& result =
843 Function::Handle(InlineCacheMissHandler(args, ic_data)); 833 Function::Handle(InlineCacheMissHandler(args, ic_data));
844 arguments.SetReturn(result); 834 arguments.SetReturn(result);
845 } 835 }
846 836
847 837
848 // Handles inline cache misses by updating the IC data array of the call site. 838 // Handles inline cache misses by updating the IC data array of the call site.
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 // of the given value. 1527 // of the given value.
1538 // Arg0: Field object; 1528 // Arg0: Field object;
1539 // Arg1: Value that is being stored. 1529 // Arg1: Value that is being stored.
1540 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) { 1530 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) {
1541 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); 1531 const Field& field = Field::CheckedHandle(arguments.ArgAt(0));
1542 const Object& value = Object::Handle(arguments.ArgAt(1)); 1532 const Object& value = Object::Handle(arguments.ArgAt(1));
1543 field.RecordStore(value); 1533 field.RecordStore(value);
1544 } 1534 }
1545 1535
1546 } // namespace dart 1536 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698