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

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

Issue 260713008: Add support for javascript incompatibility warnings. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 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) 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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 // Allocate and initialize singleton true and false boolean objects. 693 // Allocate and initialize singleton true and false boolean objects.
694 cls = Class::New<Bool>(); 694 cls = Class::New<Bool>();
695 isolate->object_store()->set_bool_class(cls); 695 isolate->object_store()->set_bool_class(cls);
696 *bool_true_ = Bool::New(true); 696 *bool_true_ = Bool::New(true);
697 *bool_false_ = Bool::New(false); 697 *bool_false_ = Bool::New(false);
698 698
699 *smi_illegal_cid_ = Smi::New(kIllegalCid); 699 *smi_illegal_cid_ = Smi::New(kIllegalCid);
700 700
701 String& error_str = String::Handle(); 701 String& error_str = String::Handle();
702 error_str = String::New("SnapshotWriter Error", Heap::kOld); 702 error_str = String::New("SnapshotWriter Error", Heap::kOld);
703 *snapshot_writer_error_ = LanguageError::New(error_str, Heap::kOld); 703 *snapshot_writer_error_ = LanguageError::New(error_str,
704 LanguageError::kError,
705 Heap::kOld);
704 error_str = String::New("Branch offset overflow", Heap::kOld); 706 error_str = String::New("Branch offset overflow", Heap::kOld);
705 *branch_offset_error_ = LanguageError::New(error_str, Heap::kOld); 707 *branch_offset_error_ = LanguageError::New(error_str,
708 LanguageError::kBailout,
709 Heap::kOld);
706 710
707 ASSERT(!null_object_->IsSmi()); 711 ASSERT(!null_object_->IsSmi());
708 ASSERT(!null_array_->IsSmi()); 712 ASSERT(!null_array_->IsSmi());
709 ASSERT(null_array_->IsArray()); 713 ASSERT(null_array_->IsArray());
710 ASSERT(!null_string_->IsSmi()); 714 ASSERT(!null_string_->IsSmi());
711 ASSERT(null_string_->IsString()); 715 ASSERT(null_string_->IsString());
712 ASSERT(!null_instance_->IsSmi()); 716 ASSERT(!null_instance_->IsSmi());
713 ASSERT(null_instance_->IsInstance()); 717 ASSERT(null_instance_->IsInstance());
714 ASSERT(!null_type_arguments_->IsSmi()); 718 ASSERT(!null_type_arguments_->IsSmi());
715 ASSERT(null_type_arguments_->IsTypeArguments()); 719 ASSERT(null_type_arguments_->IsTypeArguments());
(...skipping 7944 matching lines...) Expand 10 before | Expand all | Expand 10 after
8660 8664
8661 void Library::AddClass(const Class& cls) const { 8665 void Library::AddClass(const Class& cls) const {
8662 const String& class_name = String::Handle(cls.Name()); 8666 const String& class_name = String::Handle(cls.Name());
8663 AddObject(cls, class_name); 8667 AddObject(cls, class_name);
8664 // Link class to this library. 8668 // Link class to this library.
8665 cls.set_library(*this); 8669 cls.set_library(*this);
8666 InvalidateResolvedName(class_name); 8670 InvalidateResolvedName(class_name);
8667 } 8671 }
8668 8672
8669 static void AddScriptIfUnique(const GrowableObjectArray& scripts, 8673 static void AddScriptIfUnique(const GrowableObjectArray& scripts,
8670 Script& candidate) { 8674 const Script& candidate) {
8671 if (candidate.IsNull()) { 8675 if (candidate.IsNull()) {
8672 return; 8676 return;
8673 } 8677 }
8674 Script& script_obj = Script::Handle(); 8678 Script& script_obj = Script::Handle();
8675 8679
8676 for (int i = 0; i < scripts.Length(); i++) { 8680 for (int i = 0; i < scripts.Length(); i++) {
8677 script_obj ^= scripts.At(i); 8681 script_obj ^= scripts.At(i);
8678 if (script_obj.raw() == candidate.raw()) { 8682 if (script_obj.raw() == candidate.raw()) {
8679 // We already have a reference to this script. 8683 // We already have a reference to this script.
8680 return; 8684 return;
(...skipping 2158 matching lines...) Expand 10 before | Expand all | Expand 10 after
10839 return IssuedJSWarningBit::decode(raw_ptr()->state_bits_); 10843 return IssuedJSWarningBit::decode(raw_ptr()->state_bits_);
10840 } 10844 }
10841 10845
10842 10846
10843 void ICData::SetIssuedJSWarning() const { 10847 void ICData::SetIssuedJSWarning() const {
10844 raw_ptr()->state_bits_ = 10848 raw_ptr()->state_bits_ =
10845 IssuedJSWarningBit::update(true, raw_ptr()->state_bits_); 10849 IssuedJSWarningBit::update(true, raw_ptr()->state_bits_);
10846 } 10850 }
10847 10851
10848 10852
10853 bool ICData::MayCheckForJSWarning() const {
10854 const String& name = String::Handle(target_name());
10855 // Warning issued from native code.
10856 // Calling sequence is decoded to obtain ic data in order to check if a
10857 // warning has already been issued.
10858 if (name.Equals(Library::PrivateCoreLibName(Symbols::_instanceOf())) ||
10859 name.Equals(Library::PrivateCoreLibName(Symbols::_as()))) {
10860 return true;
10861 }
10862 // Warning issued in ic miss handler.
10863 // No decoding necessary, so allow optimization if warning already issued.
10864 if (name.Equals(Symbols::toString()) && !IssuedJSWarning()) {
10865 return true;
10866 }
10867 return false;
10868 }
10869
10870
10849 bool ICData::IsClosureCall() const { 10871 bool ICData::IsClosureCall() const {
10850 return IsClosureCallBit::decode(raw_ptr()->state_bits_); 10872 return IsClosureCallBit::decode(raw_ptr()->state_bits_);
10851 } 10873 }
10852 10874
10853 10875
10854 void ICData::SetIsClosureCall() const { 10876 void ICData::SetIsClosureCall() const {
10855 raw_ptr()->state_bits_ = 10877 raw_ptr()->state_bits_ =
10856 IsClosureCallBit::update(true, raw_ptr()->state_bits_); 10878 IsClosureCallBit::update(true, raw_ptr()->state_bits_);
10857 } 10879 }
10858 10880
(...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after
12403 va_start(args, format); 12425 va_start(args, format);
12404 RawLanguageError* result = LanguageError::NewFormattedV( 12426 RawLanguageError* result = LanguageError::NewFormattedV(
12405 prev_error, script, token_pos, kind, space, format, args); 12427 prev_error, script, token_pos, kind, space, format, args);
12406 NoGCScope no_gc; 12428 NoGCScope no_gc;
12407 va_end(args); 12429 va_end(args);
12408 return result; 12430 return result;
12409 } 12431 }
12410 12432
12411 12433
12412 RawLanguageError* LanguageError::New(const String& formatted_message, 12434 RawLanguageError* LanguageError::New(const String& formatted_message,
12435 Kind kind,
12413 Heap::Space space) { 12436 Heap::Space space) {
12414 ASSERT(Object::language_error_class() != Class::null()); 12437 ASSERT(Object::language_error_class() != Class::null());
12415 LanguageError& result = LanguageError::Handle(); 12438 LanguageError& result = LanguageError::Handle();
12416 { 12439 {
12417 RawObject* raw = Object::Allocate(LanguageError::kClassId, 12440 RawObject* raw = Object::Allocate(LanguageError::kClassId,
12418 LanguageError::InstanceSize(), 12441 LanguageError::InstanceSize(),
12419 space); 12442 space);
12420 NoGCScope no_gc; 12443 NoGCScope no_gc;
12421 result ^= raw; 12444 result ^= raw;
12422 } 12445 }
12423 result.set_formatted_message(formatted_message); 12446 result.set_formatted_message(formatted_message);
12447 result.set_kind(kind);
12424 return result.raw(); 12448 return result.raw();
12425 } 12449 }
12426 12450
12427 12451
12428 void LanguageError::set_previous_error(const Error& value) const { 12452 void LanguageError::set_previous_error(const Error& value) const {
12429 StorePointer(&raw_ptr()->previous_error_, value.raw()); 12453 StorePointer(&raw_ptr()->previous_error_, value.raw());
12430 } 12454 }
12431 12455
12432 12456
12433 void LanguageError::set_script(const Script& value) const { 12457 void LanguageError::set_script(const Script& value) const {
(...skipping 25 matching lines...) Expand all
12459 RawString* LanguageError::FormatMessage() const { 12483 RawString* LanguageError::FormatMessage() const {
12460 if (formatted_message() != String::null()) { 12484 if (formatted_message() != String::null()) {
12461 return formatted_message(); 12485 return formatted_message();
12462 } 12486 }
12463 const char* message_header; 12487 const char* message_header;
12464 switch (kind()) { 12488 switch (kind()) {
12465 case kWarning: message_header = "warning"; break; 12489 case kWarning: message_header = "warning"; break;
12466 case kError: message_header = "error"; break; 12490 case kError: message_header = "error"; break;
12467 case kMalformedType: message_header = "malformed type"; break; 12491 case kMalformedType: message_header = "malformed type"; break;
12468 case kMalboundedType: message_header = "malbounded type"; break; 12492 case kMalboundedType: message_header = "malbounded type"; break;
12493 case kBailout: message_header = "bailout"; break;
12469 default: message_header = ""; UNREACHABLE(); 12494 default: message_header = ""; UNREACHABLE();
12470 } 12495 }
12471 String& result = String::Handle(); 12496 String& result = String::Handle();
12472 String& msg = String::Handle(message()); 12497 String& msg = String::Handle(message());
12473 const Script& scr = Script::Handle(script()); 12498 const Script& scr = Script::Handle(script());
12474 if (!scr.IsNull()) { 12499 if (!scr.IsNull()) {
12475 const String& script_url = String::Handle(scr.url()); 12500 const String& script_url = String::Handle(scr.url());
12476 if (token_pos() >= 0) { 12501 if (token_pos() >= 0) {
12477 intptr_t line, column; 12502 intptr_t line, column;
12478 scr.GetTokenLocation(token_pos(), &line, &column); 12503 scr.GetTokenLocation(token_pos(), &line, &column);
(...skipping 6334 matching lines...) Expand 10 before | Expand all | Expand 10 after
18813 return tag_label.ToCString(); 18838 return tag_label.ToCString();
18814 } 18839 }
18815 18840
18816 18841
18817 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 18842 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
18818 Instance::PrintJSONImpl(stream, ref); 18843 Instance::PrintJSONImpl(stream, ref);
18819 } 18844 }
18820 18845
18821 18846
18822 } // namespace dart 18847 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.h » ('j') | runtime/vm/symbols.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698