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

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

Issue 735543003: Range feedback for binary integer operations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: ready for review Created 6 years 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 11454 matching lines...) Expand 10 before | Expand all | Expand 10 after
11465 } 11465 }
11466 // Warning issued in ic miss handler. 11466 // Warning issued in ic miss handler.
11467 // No decoding necessary, so allow optimization if warning already issued. 11467 // No decoding necessary, so allow optimization if warning already issued.
11468 if (name.Equals(Symbols::toString()) && !IssuedJSWarning()) { 11468 if (name.Equals(Symbols::toString()) && !IssuedJSWarning()) {
11469 return true; 11469 return true;
11470 } 11470 }
11471 return false; 11471 return false;
11472 } 11472 }
11473 11473
11474 11474
11475 void ICData::set_range_feedback(uint32_t feedback) {
11476 StoreNonPointer(&raw_ptr()->range_feedback_, feedback);
11477 }
11478
11479
11475 void ICData::set_state_bits(uint32_t bits) const { 11480 void ICData::set_state_bits(uint32_t bits) const {
11476 StoreNonPointer(&raw_ptr()->state_bits_, bits); 11481 StoreNonPointer(&raw_ptr()->state_bits_, bits);
11477 } 11482 }
11478 11483
11479 11484
11480 intptr_t ICData::TestEntryLengthFor(intptr_t num_args) { 11485 intptr_t ICData::TestEntryLengthFor(intptr_t num_args) {
11481 return num_args + 1 /* target function*/ + 1 /* frequency */; 11486 return num_args + 1 /* target function*/ + 1 /* frequency */;
11482 } 11487 }
11483 11488
11484 11489
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
11920 ICData::InstanceSize(), 11925 ICData::InstanceSize(),
11921 Heap::kOld); 11926 Heap::kOld);
11922 NoGCScope no_gc; 11927 NoGCScope no_gc;
11923 result ^= raw; 11928 result ^= raw;
11924 } 11929 }
11925 result.set_owner(owner); 11930 result.set_owner(owner);
11926 result.set_target_name(target_name); 11931 result.set_target_name(target_name);
11927 result.set_arguments_descriptor(arguments_descriptor); 11932 result.set_arguments_descriptor(arguments_descriptor);
11928 result.set_deopt_id(deopt_id); 11933 result.set_deopt_id(deopt_id);
11929 result.set_state_bits(0); 11934 result.set_state_bits(0);
11935 result.set_range_feedback(0);
11930 result.SetNumArgsTested(num_args_tested); 11936 result.SetNumArgsTested(num_args_tested);
11931 // Number of array elements in one test entry. 11937 // Number of array elements in one test entry.
11932 intptr_t len = result.TestEntryLength(); 11938 intptr_t len = result.TestEntryLength();
11933 // IC data array must be null terminated (sentinel entry). 11939 // IC data array must be null terminated (sentinel entry).
11934 const Array& ic_data = Array::Handle(Array::New(len, Heap::kOld)); 11940 const Array& ic_data = Array::Handle(Array::New(len, Heap::kOld));
11935 result.set_ic_data(ic_data); 11941 result.set_ic_data(ic_data);
11936 result.WriteSentinel(ic_data); 11942 result.WriteSentinel(ic_data);
11937 return result.raw(); 11943 return result.raw();
11938 } 11944 }
11939 11945
11940 11946
11941 void ICData::PrintJSONImpl(JSONStream* stream, bool ref) const { 11947 void ICData::PrintJSONImpl(JSONStream* stream, bool ref) const {
11942 Object::PrintJSONImpl(stream, ref); 11948 Object::PrintJSONImpl(stream, ref);
11943 } 11949 }
11944 11950
11945 11951
11952 static Token::Kind RecognizeArithmeticOp(const String& name) {
srdjan 2014/12/15 16:39:01 ASSERT(name.IsSymbol()).
Vyacheslav Egorov (Google) 2014/12/15 17:20:05 Done.
11953 if (name.raw() == Symbols::Plus().raw()) {
11954 return Token::kADD;
11955 } else if (name.raw() == Symbols::Minus().raw()) {
11956 return Token::kSUB;
11957 } else if (name.raw() == Symbols::Star().raw()) {
11958 return Token::kMUL;
11959 } else if (name.raw() == Symbols::Slash().raw()) {
11960 return Token::kDIV;
11961 } else if (name.raw() == Symbols::TruncDivOperator().raw()) {
11962 return Token::kTRUNCDIV;
11963 } else if (name.raw() == Symbols::Percent().raw()) {
11964 return Token::kMOD;
11965 } else if (name.raw() == Symbols::BitOr().raw()) {
11966 return Token::kBIT_OR;
11967 } else if (name.raw() == Symbols::Ampersand().raw()) {
11968 return Token::kBIT_AND;
11969 } else if (name.raw() == Symbols::Caret().raw()) {
11970 return Token::kBIT_XOR;
11971 } else if (name.raw() == Symbols::LeftShiftOperator().raw()) {
11972 return Token::kSHL;
11973 } else if (name.raw() == Symbols::RightShiftOperator().raw()) {
11974 return Token::kSHR;
11975 } else if (name.raw() == Symbols::Tilde().raw()) {
11976 return Token::kBIT_NOT;
11977 } else if (name.raw() == Symbols::UnaryMinus().raw()) {
11978 return Token::kNEGATE;
11979 }
11980 return Token::kILLEGAL;
11981 }
11982
11983
11984 bool ICData::HasRangeFeedback() const {
11985 const String& target = String::Handle(target_name());
11986 const Token::Kind token_kind = RecognizeArithmeticOp(target);
11987 if (!Token::IsBinaryArithmeticOperator(token_kind) &&
11988 !Token::IsUnaryArithmeticOperator(token_kind)) {
11989 return false;
11990 }
11991
11992 bool initialized = false;
11993 Function& t = Function::Handle();
11994 const intptr_t len = NumberOfChecks();
11995 GrowableArray<intptr_t> class_ids;
11996 for (intptr_t i = 0; i < len; i++) {
11997 if (IsUsedAt(i)) {
11998 initialized = true;
11999 GetCheckAt(i, &class_ids, &t);
12000 for (intptr_t j = 0; j < class_ids.length(); j++) {
12001 const intptr_t cid = class_ids[j];
12002 if (cid != kSmiCid && cid != kMintCid) {
srdjan 2014/12/15 16:39:01 Add parentheses
Vyacheslav Egorov (Google) 2014/12/15 17:20:04 Done.
12003 return false;
12004 }
12005 }
12006 }
12007 }
12008
12009 return initialized;
12010 }
12011
12012
12013 ICData::RangeFeedback ICData::DecodeRangeFeedbackAt(intptr_t idx) const {
12014 ASSERT((0 <= idx) && (idx < 3));
12015 const uint32_t feedback =
12016 (range_feedback() >> (idx * kBitsPerRangeFeedback)) & kRangeFeedbackMask;
12017 if ((feedback & kInt64Bit) != 0) {
12018 return kInt64Range;
12019 }
12020
12021 if ((feedback & kUint32Bit) != 0) {
12022 return ((feedback & kSignBit) != 0) ? kInt64Range : kUint32Range;
12023 }
12024
12025 if ((feedback & kInt32Bit) != 0) {
12026 return kInt32Range;
12027 }
12028
12029 return kSmiRange;
12030 }
12031
12032
11946 Code::Comments& Code::Comments::New(intptr_t count) { 12033 Code::Comments& Code::Comments::New(intptr_t count) {
11947 Comments* comments; 12034 Comments* comments;
11948 if (count < 0 || count > (kIntptrMax / kNumberOfEntries)) { 12035 if (count < 0 || count > (kIntptrMax / kNumberOfEntries)) {
11949 // This should be caught before we reach here. 12036 // This should be caught before we reach here.
11950 FATAL1("Fatal error in Code::Comments::New: invalid count %" Pd "\n", 12037 FATAL1("Fatal error in Code::Comments::New: invalid count %" Pd "\n",
11951 count); 12038 count);
11952 } 12039 }
11953 if (count == 0) { 12040 if (count == 0) {
11954 comments = new Comments(Object::empty_array()); 12041 comments = new Comments(Object::empty_array());
11955 } else { 12042 } else {
(...skipping 8534 matching lines...) Expand 10 before | Expand all | Expand 10 after
20490 return tag_label.ToCString(); 20577 return tag_label.ToCString();
20491 } 20578 }
20492 20579
20493 20580
20494 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20581 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20495 Instance::PrintJSONImpl(stream, ref); 20582 Instance::PrintJSONImpl(stream, ref);
20496 } 20583 }
20497 20584
20498 20585
20499 } // namespace dart 20586 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698