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

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

Issue 9949020: Move HandlerList to shared ExceptionHandlerList. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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
« no previous file with comments | « runtime/vm/code_generator_ia32.h ('k') | runtime/vm/code_generator_x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 codegen_->set_state(this); 52 codegen_->set_state(this);
53 } 53 }
54 54
55 55
56 CodeGeneratorState::~CodeGeneratorState() { 56 CodeGeneratorState::~CodeGeneratorState() {
57 codegen_->set_state(parent_); 57 codegen_->set_state(parent_);
58 } 58 }
59 59
60 60
61 class CodeGenerator::HandlerList : public ZoneAllocated {
62 public:
63 struct HandlerDesc {
64 intptr_t try_index; // Try block index handled by the handler.
65 intptr_t pc_offset; // Handler PC offset value.
66 };
67
68 HandlerList() : list_() {
69 }
70 ~HandlerList() { }
71
72 intptr_t Length() const {
73 return list_.length();
74 }
75
76 intptr_t TryIndex(int index) const {
77 return list_[index].try_index;
78 }
79 intptr_t PcOffset(int index) const {
80 return list_[index].pc_offset;
81 }
82 void SetPcOffset(int index, intptr_t handler_pc) {
83 list_[index].pc_offset = handler_pc;
84 }
85
86 void AddHandler(intptr_t try_index, intptr_t pc_offset) {
87 struct HandlerDesc data;
88 data.try_index = try_index;
89 data.pc_offset = pc_offset;
90 list_.Add(data);
91 }
92
93 RawExceptionHandlers* FinalizeExceptionHandlers(uword entry_point) {
94 intptr_t num_handlers = Length();
95 const ExceptionHandlers& handlers =
96 ExceptionHandlers::Handle(ExceptionHandlers::New(num_handlers));
97 for (intptr_t i = 0; i < num_handlers; i++) {
98 handlers.SetHandlerEntry(i, TryIndex(i), (entry_point + PcOffset(i)));
99 }
100 return handlers.raw();
101 }
102
103 private:
104 GrowableArray<struct HandlerDesc> list_;
105 DISALLOW_COPY_AND_ASSIGN(HandlerList);
106 };
107
108
109 CodeGenerator::CodeGenerator(Assembler* assembler, 61 CodeGenerator::CodeGenerator(Assembler* assembler,
110 const ParsedFunction& parsed_function) 62 const ParsedFunction& parsed_function)
111 : assembler_(assembler), 63 : assembler_(assembler),
112 parsed_function_(parsed_function), 64 parsed_function_(parsed_function),
113 locals_space_size_(-1), 65 locals_space_size_(-1),
114 state_(NULL), 66 state_(NULL),
115 pc_descriptors_list_(NULL), 67 pc_descriptors_list_(NULL),
116 stackmap_builder_(NULL), 68 stackmap_builder_(NULL),
117 exception_handlers_list_(NULL), 69 exception_handlers_list_(NULL),
118 try_index_(CatchClauseNode::kInvalidTryIndex), 70 try_index_(CatchClauseNode::kInvalidTryIndex),
119 context_level_(0) { 71 context_level_(0) {
120 ASSERT(assembler_ != NULL); 72 ASSERT(assembler_ != NULL);
121 ASSERT(parsed_function.node_sequence() != NULL); 73 ASSERT(parsed_function.node_sequence() != NULL);
122 ASSERT(Isolate::Current()->long_jump_base()->IsSafeToJump()); 74 ASSERT(Isolate::Current()->long_jump_base()->IsSafeToJump());
123 pc_descriptors_list_ = new DescriptorList(); 75 pc_descriptors_list_ = new DescriptorList();
124 // We do not build any stack maps in the unoptimizing compiler. 76 // We do not build any stack maps in the unoptimizing compiler.
125 exception_handlers_list_ = new CodeGenerator::HandlerList(); 77 exception_handlers_list_ = new ExceptionHandlerList();
126 } 78 }
127 79
128 80
129 void CodeGenerator::IntrinsifyGetter() { 81 void CodeGenerator::IntrinsifyGetter() {
130 // TOS: return address. 82 // TOS: return address.
131 // +1 : receiver. 83 // +1 : receiver.
132 // Sequence node has one return node, its input is oad field node. 84 // Sequence node has one return node, its input is oad field node.
133 const SequenceNode& sequence_node = *parsed_function_.node_sequence(); 85 const SequenceNode& sequence_node = *parsed_function_.node_sequence();
134 ASSERT(sequence_node.length() == 1); 86 ASSERT(sequence_node.length() == 1);
135 ASSERT(sequence_node.NodeAt(0)->IsReturnNode()); 87 ASSERT(sequence_node.NodeAt(0)->IsReturnNode());
(...skipping 2701 matching lines...) Expand 10 before | Expand all | Expand 10 after
2837 const Error& error = Error::Handle( 2789 const Error& error = Error::Handle(
2838 Parser::FormatError(script, token_index, "Error", format, args)); 2790 Parser::FormatError(script, token_index, "Error", format, args));
2839 va_end(args); 2791 va_end(args);
2840 Isolate::Current()->long_jump_base()->Jump(1, error); 2792 Isolate::Current()->long_jump_base()->Jump(1, error);
2841 UNREACHABLE(); 2793 UNREACHABLE();
2842 } 2794 }
2843 2795
2844 } // namespace dart 2796 } // namespace dart
2845 2797
2846 #endif // defined TARGET_ARCH_IA32 2798 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/code_generator_ia32.h ('k') | runtime/vm/code_generator_x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698