| 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/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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } | 52 } |
| 53 codegen_->set_state(this); | 53 codegen_->set_state(this); |
| 54 } | 54 } |
| 55 | 55 |
| 56 | 56 |
| 57 CodeGeneratorState::~CodeGeneratorState() { | 57 CodeGeneratorState::~CodeGeneratorState() { |
| 58 codegen_->set_state(parent_); | 58 codegen_->set_state(parent_); |
| 59 } | 59 } |
| 60 | 60 |
| 61 | 61 |
| 62 class CodeGenerator::DescriptorList : public ZoneAllocated { | |
| 63 public: | |
| 64 struct PcDesc { | |
| 65 intptr_t pc_offset; // PC offset value of the descriptor. | |
| 66 PcDescriptors::Kind kind; // Descriptor kind (kDeopt, kOther). | |
| 67 intptr_t node_id; // AST node id. | |
| 68 intptr_t token_index; // Token position in source of PC. | |
| 69 intptr_t try_index; // Try block index of PC. | |
| 70 }; | |
| 71 | |
| 72 DescriptorList() : list_() { | |
| 73 } | |
| 74 ~DescriptorList() { } | |
| 75 | |
| 76 intptr_t Length() const { | |
| 77 return list_.length(); | |
| 78 } | |
| 79 | |
| 80 intptr_t PcOffset(int index) const { | |
| 81 return list_[index].pc_offset; | |
| 82 } | |
| 83 PcDescriptors::Kind Kind(int index) const { | |
| 84 return list_[index].kind; | |
| 85 } | |
| 86 intptr_t NodeId(int index) const { | |
| 87 return list_[index].node_id; | |
| 88 } | |
| 89 intptr_t TokenIndex(int index) const { | |
| 90 return list_[index].token_index; | |
| 91 } | |
| 92 intptr_t TryIndex(int index) const { | |
| 93 return list_[index].try_index; | |
| 94 } | |
| 95 | |
| 96 void AddDescriptor(PcDescriptors::Kind kind, | |
| 97 intptr_t pc_offset, | |
| 98 intptr_t node_id, | |
| 99 intptr_t token_index, | |
| 100 intptr_t try_index) { | |
| 101 struct PcDesc data; | |
| 102 data.pc_offset = pc_offset; | |
| 103 data.kind = kind; | |
| 104 data.node_id = node_id; | |
| 105 data.token_index = token_index; | |
| 106 data.try_index = try_index; | |
| 107 list_.Add(data); | |
| 108 } | |
| 109 | |
| 110 RawPcDescriptors* FinalizePcDescriptors(uword entry_point) { | |
| 111 intptr_t num_descriptors = Length(); | |
| 112 const PcDescriptors& descriptors = | |
| 113 PcDescriptors::Handle(PcDescriptors::New(num_descriptors)); | |
| 114 for (intptr_t i = 0; i < num_descriptors; i++) { | |
| 115 descriptors.AddDescriptor(i, | |
| 116 (entry_point + PcOffset(i)), | |
| 117 Kind(i), | |
| 118 NodeId(i), | |
| 119 TokenIndex(i), | |
| 120 TryIndex(i)); | |
| 121 } | |
| 122 return descriptors.raw(); | |
| 123 } | |
| 124 | |
| 125 private: | |
| 126 GrowableArray<struct PcDesc> list_; | |
| 127 DISALLOW_COPY_AND_ASSIGN(DescriptorList); | |
| 128 }; | |
| 129 | |
| 130 | |
| 131 class CodeGenerator::HandlerList : public ZoneAllocated { | 62 class CodeGenerator::HandlerList : public ZoneAllocated { |
| 132 public: | 63 public: |
| 133 struct HandlerDesc { | 64 struct HandlerDesc { |
| 134 intptr_t try_index; // Try block index handled by the handler. | 65 intptr_t try_index; // Try block index handled by the handler. |
| 135 intptr_t pc_offset; // Handler PC offset value. | 66 intptr_t pc_offset; // Handler PC offset value. |
| 136 }; | 67 }; |
| 137 | 68 |
| 138 HandlerList() : list_() { | 69 HandlerList() : list_() { |
| 139 } | 70 } |
| 140 ~HandlerList() { } | 71 ~HandlerList() { } |
| (...skipping 2673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2814 const Error& error = Error::Handle( | 2745 const Error& error = Error::Handle( |
| 2815 Parser::FormatError(script, token_index, "Error", format, args)); | 2746 Parser::FormatError(script, token_index, "Error", format, args)); |
| 2816 va_end(args); | 2747 va_end(args); |
| 2817 Isolate::Current()->long_jump_base()->Jump(1, error); | 2748 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2818 UNREACHABLE(); | 2749 UNREACHABLE(); |
| 2819 } | 2750 } |
| 2820 | 2751 |
| 2821 } // namespace dart | 2752 } // namespace dart |
| 2822 | 2753 |
| 2823 #endif // defined TARGET_ARCH_IA32 | 2754 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |