| OLD | NEW |
| 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/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 6455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6466 return static_cast<PcDescriptors::Kind>(*(EntryAddr(index, kKindEntry))); | 6466 return static_cast<PcDescriptors::Kind>(*(EntryAddr(index, kKindEntry))); |
| 6467 } | 6467 } |
| 6468 | 6468 |
| 6469 | 6469 |
| 6470 void PcDescriptors::SetKind(intptr_t index, PcDescriptors::Kind value) const { | 6470 void PcDescriptors::SetKind(intptr_t index, PcDescriptors::Kind value) const { |
| 6471 *(EntryAddr(index, kKindEntry)) = value; | 6471 *(EntryAddr(index, kKindEntry)) = value; |
| 6472 } | 6472 } |
| 6473 | 6473 |
| 6474 | 6474 |
| 6475 intptr_t PcDescriptors::DeoptId(intptr_t index) const { | 6475 intptr_t PcDescriptors::DeoptId(intptr_t index) const { |
| 6476 return Smi::Value(*SmiAddr(index, kDeoptIdEntry)); | 6476 return *(EntryAddr(index, kDeoptIdEntry)); |
| 6477 } | 6477 } |
| 6478 | 6478 |
| 6479 | 6479 |
| 6480 void PcDescriptors::SetDeoptId(intptr_t index, intptr_t value) const { | 6480 void PcDescriptors::SetDeoptId(intptr_t index, intptr_t value) const { |
| 6481 *SmiAddr(index, kDeoptIdEntry) = Smi::New(value); | 6481 *(EntryAddr(index, kDeoptIdEntry)) = value; |
| 6482 } | 6482 } |
| 6483 | 6483 |
| 6484 | 6484 |
| 6485 intptr_t PcDescriptors::TokenPos(intptr_t index) const { | 6485 intptr_t PcDescriptors::TokenPos(intptr_t index) const { |
| 6486 return Smi::Value(*SmiAddr(index, kTokenPosEntry)); | 6486 ASSERT(DescriptorKind(index) != kDeoptIndex); |
| 6487 return *(EntryAddr(index, kTokenPosEntry)); |
| 6487 } | 6488 } |
| 6488 | 6489 |
| 6489 | 6490 |
| 6490 void PcDescriptors::SetTokenPos(intptr_t index, intptr_t value) const { | 6491 void PcDescriptors::SetTokenPos(intptr_t index, intptr_t value) const { |
| 6491 *SmiAddr(index, kTokenPosEntry) = Smi::New(value); | 6492 *(EntryAddr(index, kTokenPosEntry)) = value; |
| 6492 } | 6493 } |
| 6493 | 6494 |
| 6494 | 6495 |
| 6495 intptr_t PcDescriptors::TryIndex(intptr_t index) const { | 6496 intptr_t PcDescriptors::TryIndex(intptr_t index) const { |
| 6496 ASSERT(DescriptorKind(index) != kDeoptIndex); | 6497 ASSERT(DescriptorKind(index) != kDeoptIndex); |
| 6497 return *(EntryAddr(index, kTryIndexEntry)); | 6498 return *(EntryAddr(index, kTryIndexEntry)); |
| 6498 } | 6499 } |
| 6499 | 6500 |
| 6500 | 6501 |
| 6501 intptr_t PcDescriptors::DeoptIndex(intptr_t index) const { | |
| 6502 ASSERT(DescriptorKind(index) == kDeoptIndex); | |
| 6503 return *(EntryAddr(index, kTryIndexEntry)); | |
| 6504 } | |
| 6505 | |
| 6506 | |
| 6507 void PcDescriptors::SetTryIndex(intptr_t index, intptr_t value) const { | 6502 void PcDescriptors::SetTryIndex(intptr_t index, intptr_t value) const { |
| 6508 *(EntryAddr(index, kTryIndexEntry)) = value; | 6503 *(EntryAddr(index, kTryIndexEntry)) = value; |
| 6509 } | 6504 } |
| 6510 | 6505 |
| 6511 | 6506 |
| 6507 intptr_t PcDescriptors::DeoptIndex(intptr_t index) const { |
| 6508 ASSERT(DescriptorKind(index) == kDeoptIndex); |
| 6509 return *(EntryAddr(index, kDeoptIndexEntry)); |
| 6510 } |
| 6511 |
| 6512 |
| 6513 intptr_t PcDescriptors::DeoptReason(intptr_t index) const { |
| 6514 ASSERT(DescriptorKind(index) == kDeoptIndex); |
| 6515 return *(EntryAddr(index, kDeoptReasonEntry)); |
| 6516 } |
| 6517 |
| 6518 |
| 6512 RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors) { | 6519 RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors) { |
| 6513 ASSERT(Object::pc_descriptors_class() != Class::null()); | 6520 ASSERT(Object::pc_descriptors_class() != Class::null()); |
| 6514 if (num_descriptors < 0 || num_descriptors > kMaxElements) { | 6521 if (num_descriptors < 0 || num_descriptors > kMaxElements) { |
| 6515 // This should be caught before we reach here. | 6522 // This should be caught before we reach here. |
| 6516 FATAL1("Fatal error in PcDescriptors::New: invalid num_descriptors %ld\n", | 6523 FATAL1("Fatal error in PcDescriptors::New: invalid num_descriptors %ld\n", |
| 6517 num_descriptors); | 6524 num_descriptors); |
| 6518 } | 6525 } |
| 6519 PcDescriptors& result = PcDescriptors::Handle(); | 6526 PcDescriptors& result = PcDescriptors::Handle(); |
| 6520 { | 6527 { |
| 6521 uword size = PcDescriptors::InstanceSize(num_descriptors); | 6528 uword size = PcDescriptors::InstanceSize(num_descriptors); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 6547 | 6554 |
| 6548 const char* PcDescriptors::ToCString() const { | 6555 const char* PcDescriptors::ToCString() const { |
| 6549 if (Length() == 0) { | 6556 if (Length() == 0) { |
| 6550 return "No pc descriptors\n"; | 6557 return "No pc descriptors\n"; |
| 6551 } | 6558 } |
| 6552 const char* kFormat = | 6559 const char* kFormat = |
| 6553 "0x%" PRIxPTR "\t%s\t%" PRIdPTR "\t%" PRIdPTR "\t%" PRIdPTR "\n"; | 6560 "0x%" PRIxPTR "\t%s\t%" PRIdPTR "\t%" PRIdPTR "\t%" PRIdPTR "\n"; |
| 6554 // First compute the buffer size required. | 6561 // First compute the buffer size required. |
| 6555 intptr_t len = 1; // Trailing '\0'. | 6562 intptr_t len = 1; // Trailing '\0'. |
| 6556 for (intptr_t i = 0; i < Length(); i++) { | 6563 for (intptr_t i = 0; i < Length(); i++) { |
| 6557 const intptr_t multi_purpose_index = DescriptorKind(i) == kDeoptIndex ? | 6564 intptr_t token_pos_or_deopt_reason = DescriptorKind(i) == kDeoptIndex ? |
| 6565 DeoptReason(i) : TokenPos(i); |
| 6566 intptr_t multi_purpose_index = DescriptorKind(i) == kDeoptIndex ? |
| 6558 DeoptIndex(i) : TryIndex(i); | 6567 DeoptIndex(i) : TryIndex(i); |
| 6559 len += OS::SNPrint(NULL, 0, kFormat, | 6568 len += OS::SNPrint(NULL, 0, kFormat, |
| 6560 PC(i), KindAsStr(i), DeoptId(i), TokenPos(i), multi_purpose_index); | 6569 PC(i), |
| 6570 KindAsStr(i), |
| 6571 DeoptId(i), |
| 6572 token_pos_or_deopt_reason, |
| 6573 multi_purpose_index); |
| 6561 } | 6574 } |
| 6562 // Allocate the buffer. | 6575 // Allocate the buffer. |
| 6563 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); | 6576 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 6564 // Layout the fields in the buffer. | 6577 // Layout the fields in the buffer. |
| 6565 intptr_t index = 0; | 6578 intptr_t index = 0; |
| 6566 for (intptr_t i = 0; i < Length(); i++) { | 6579 for (intptr_t i = 0; i < Length(); i++) { |
| 6567 const intptr_t multi_purpose_index = DescriptorKind(i) == kDeoptIndex ? | 6580 intptr_t token_pos_or_deopt_reason = DescriptorKind(i) == kDeoptIndex ? |
| 6581 DeoptReason(i) : TokenPos(i); |
| 6582 intptr_t multi_purpose_index = DescriptorKind(i) == kDeoptIndex ? |
| 6568 DeoptIndex(i) : TryIndex(i); | 6583 DeoptIndex(i) : TryIndex(i); |
| 6569 index += OS::SNPrint((buffer + index), (len - index), kFormat, | 6584 index += OS::SNPrint((buffer + index), (len - index), kFormat, |
| 6570 PC(i), KindAsStr(i), DeoptId(i), TokenPos(i), multi_purpose_index); | 6585 PC(i), |
| 6586 KindAsStr(i), |
| 6587 DeoptId(i), |
| 6588 token_pos_or_deopt_reason, |
| 6589 multi_purpose_index); |
| 6571 } | 6590 } |
| 6572 return buffer; | 6591 return buffer; |
| 6573 } | 6592 } |
| 6574 | 6593 |
| 6575 | 6594 |
| 6576 // Verify assumptions (in debug mode only). | 6595 // Verify assumptions (in debug mode only). |
| 6577 // - No two deopt descriptors have the same deoptimization id. | 6596 // - No two deopt descriptors have the same deoptimization id. |
| 6578 // - No two ic-call descriptors have the same deoptimization id (type feedback). | 6597 // - No two ic-call descriptors have the same deoptimization id (type feedback). |
| 6579 // - No two descriptors of same kind have the same PC. | 6598 // - No two descriptors of same kind have the same PC. |
| 6580 // A function without unique ids is marked as non-optimizable (e.g., because of | 6599 // A function without unique ids is marked as non-optimizable (e.g., because of |
| (...skipping 4385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10966 const char* JSRegExp::ToCString() const { | 10985 const char* JSRegExp::ToCString() const { |
| 10967 const String& str = String::Handle(pattern()); | 10986 const String& str = String::Handle(pattern()); |
| 10968 const char* format = "JSRegExp: pattern=%s flags=%s"; | 10987 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 10969 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 10988 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 10970 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); | 10989 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); |
| 10971 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 10990 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 10972 return chars; | 10991 return chars; |
| 10973 } | 10992 } |
| 10974 | 10993 |
| 10975 } // namespace dart | 10994 } // namespace dart |
| OLD | NEW |