Chromium Code Reviews| 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/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
| 6 | 6 |
| 7 #include "vm/ast_printer.h" | 7 #include "vm/ast_printer.h" |
| 8 #include "vm/bit_vector.h" | 8 #include "vm/bit_vector.h" |
| 9 #include "vm/code_descriptors.h" | 9 #include "vm/code_descriptors.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 Computation* EffectGraphVisitor::BuildStoreLocal( | 150 Computation* EffectGraphVisitor::BuildStoreLocal( |
| 151 const LocalVariable& local, Value* value) { | 151 const LocalVariable& local, Value* value) { |
| 152 if (local.is_captured()) { | 152 if (local.is_captured()) { |
| 153 intptr_t delta = owner()->context_level() - | 153 intptr_t delta = owner()->context_level() - |
| 154 local.owner()->context_level(); | 154 local.owner()->context_level(); |
| 155 ASSERT(delta >= 0); | 155 ASSERT(delta >= 0); |
| 156 BindInstr* context = new BindInstr(new CurrentContextComp()); | 156 BindInstr* context = new BindInstr(new CurrentContextComp()); |
| 157 AddInstruction(context); | 157 AddInstruction(context); |
| 158 Value* context_value = new UseVal(context); | 158 Value* context_value = new UseVal(context); |
| 159 while (delta-- > 0) { | 159 while (delta-- > 0) { |
| 160 BindInstr* load = new BindInstr(new NativeLoadFieldComp( | 160 BindInstr* load = new BindInstr(new LoadVMFieldComp( |
| 161 context_value, Context::parent_offset(), Type::ZoneHandle())); | 161 context_value, Context::parent_offset(), Type::ZoneHandle())); |
| 162 AddInstruction(load); | 162 AddInstruction(load); |
| 163 context_value = new UseVal(load); | 163 context_value = new UseVal(load); |
| 164 } | 164 } |
| 165 Computation* store = new NativeStoreFieldComp( | 165 Computation* store = new StoreVMFieldComp( |
|
Florian Schneider
2012/05/24 01:15:47
return new StoreFieldComp(
Florian Schneider
2012/05/24 01:16:32
I mean of course:
return new StoreVMFieldComp(
Ivan Posva
2012/05/29 17:35:04
Done.
| |
| 166 context_value, | 166 context_value, |
| 167 Context::variable_offset(local.index()), | 167 Context::variable_offset(local.index()), |
| 168 value, | 168 value, |
| 169 local.type()); | 169 local.type()); |
| 170 return store; | 170 return store; |
| 171 } else { | 171 } else { |
| 172 return new StoreLocalComp(local, value, owner()->context_level()); | 172 return new StoreLocalComp(local, value, owner()->context_level()); |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 | 176 |
| 177 Computation* EffectGraphVisitor::BuildLoadLocal(const LocalVariable& local) { | 177 Computation* EffectGraphVisitor::BuildLoadLocal(const LocalVariable& local) { |
| 178 if (local.is_captured()) { | 178 if (local.is_captured()) { |
| 179 intptr_t delta = owner()->context_level() - | 179 intptr_t delta = owner()->context_level() - |
| 180 local.owner()->context_level(); | 180 local.owner()->context_level(); |
| 181 ASSERT(delta >= 0); | 181 ASSERT(delta >= 0); |
| 182 BindInstr* context = new BindInstr(new CurrentContextComp()); | 182 BindInstr* context = new BindInstr(new CurrentContextComp()); |
| 183 AddInstruction(context); | 183 AddInstruction(context); |
| 184 Value* context_value = new UseVal(context); | 184 Value* context_value = new UseVal(context); |
| 185 while (delta-- > 0) { | 185 while (delta-- > 0) { |
| 186 BindInstr* load = new BindInstr(new NativeLoadFieldComp( | 186 BindInstr* load = new BindInstr(new LoadVMFieldComp( |
| 187 context_value, Context::parent_offset(), Type::ZoneHandle())); | 187 context_value, Context::parent_offset(), Type::ZoneHandle())); |
| 188 AddInstruction(load); | 188 AddInstruction(load); |
| 189 context_value = new UseVal(load); | 189 context_value = new UseVal(load); |
| 190 } | 190 } |
| 191 Computation* store = new NativeLoadFieldComp( | 191 Computation* store = new LoadVMFieldComp( |
|
Florian Schneider
2012/05/24 01:15:47
Computation* store = ...
does not make sense here
Ivan Posva
2012/05/29 17:35:04
Done.
| |
| 192 context_value, Context::variable_offset(local.index()), local.type()); | 192 context_value, Context::variable_offset(local.index()), local.type()); |
| 193 return store; | 193 return store; |
| 194 } else { | 194 } else { |
| 195 return new LoadLocalComp(local, owner()->context_level()); | 195 return new LoadLocalComp(local, owner()->context_level()); |
| 196 } | 196 } |
| 197 } | 197 } |
| 198 | 198 |
| 199 | 199 |
| 200 // Stores current context into the 'variable' | 200 // Stores current context into the 'variable' |
| 201 void EffectGraphVisitor::BuildStoreContext(const LocalVariable& variable) { | 201 void EffectGraphVisitor::BuildStoreContext(const LocalVariable& variable) { |
| (...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1578 } | 1578 } |
| 1579 // The instantiator is the receiver of the caller, which is not a factory. | 1579 // The instantiator is the receiver of the caller, which is not a factory. |
| 1580 // The receiver cannot be null; extract its AbstractTypeArguments object. | 1580 // The receiver cannot be null; extract its AbstractTypeArguments object. |
| 1581 // Note that in the factory case, the instantiator is the first parameter | 1581 // Note that in the factory case, the instantiator is the first parameter |
| 1582 // of the factory, i.e. already an AbstractTypeArguments object. | 1582 // of the factory, i.e. already an AbstractTypeArguments object. |
| 1583 intptr_t type_arguments_instance_field_offset = | 1583 intptr_t type_arguments_instance_field_offset = |
| 1584 instantiator_class.type_arguments_instance_field_offset(); | 1584 instantiator_class.type_arguments_instance_field_offset(); |
| 1585 ASSERT(type_arguments_instance_field_offset != Class::kNoTypeArguments); | 1585 ASSERT(type_arguments_instance_field_offset != Class::kNoTypeArguments); |
| 1586 | 1586 |
| 1587 BindInstr* load = | 1587 BindInstr* load = |
| 1588 new BindInstr(new NativeLoadFieldComp( | 1588 new BindInstr(new LoadVMFieldComp( |
| 1589 instantiator, | 1589 instantiator, |
| 1590 type_arguments_instance_field_offset, | 1590 type_arguments_instance_field_offset, |
| 1591 Type::ZoneHandle())); // Not an instance, no type. | 1591 Type::ZoneHandle())); // Not an instance, no type. |
| 1592 AddInstruction(load); | 1592 AddInstruction(load); |
| 1593 return new UseVal(load); | 1593 return new UseVal(load); |
| 1594 } | 1594 } |
| 1595 | 1595 |
| 1596 | 1596 |
| 1597 Definition* EffectGraphVisitor::BuildInstantiatedTypeArguments( | 1597 Definition* EffectGraphVisitor::BuildInstantiatedTypeArguments( |
| 1598 intptr_t token_index, | 1598 intptr_t token_index, |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1931 return (node == owner()->parsed_function().node_sequence()) && | 1931 return (node == owner()->parsed_function().node_sequence()) && |
| 1932 (owner()->parsed_function().saved_context_var() != NULL); | 1932 (owner()->parsed_function().saved_context_var() != NULL); |
| 1933 } | 1933 } |
| 1934 | 1934 |
| 1935 | 1935 |
| 1936 void EffectGraphVisitor::UnchainContext() { | 1936 void EffectGraphVisitor::UnchainContext() { |
| 1937 BindInstr* context = new BindInstr(new CurrentContextComp()); | 1937 BindInstr* context = new BindInstr(new CurrentContextComp()); |
| 1938 AddInstruction(context); | 1938 AddInstruction(context); |
| 1939 BindInstr* parent = | 1939 BindInstr* parent = |
| 1940 new BindInstr( | 1940 new BindInstr( |
| 1941 new NativeLoadFieldComp( | 1941 new LoadVMFieldComp( |
| 1942 new UseVal(context), | 1942 new UseVal(context), |
| 1943 Context::parent_offset(), | 1943 Context::parent_offset(), |
| 1944 Type::ZoneHandle())); // Not an instance, no type. | 1944 Type::ZoneHandle())); // Not an instance, no type. |
| 1945 AddInstruction(parent); | 1945 AddInstruction(parent); |
| 1946 AddInstruction(new DoInstr(new StoreContextComp(new UseVal(parent)))); | 1946 AddInstruction(new DoInstr(new StoreContextComp(new UseVal(parent)))); |
| 1947 } | 1947 } |
| 1948 | 1948 |
| 1949 | 1949 |
| 1950 // <Statement> ::= Sequence { scope: LocalScope | 1950 // <Statement> ::= Sequence { scope: LocalScope |
| 1951 // nodes: <Statement>* | 1951 // nodes: <Statement>* |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2399 char* chars = reinterpret_cast<char*>( | 2399 char* chars = reinterpret_cast<char*>( |
| 2400 Isolate::Current()->current_zone()->Allocate(len)); | 2400 Isolate::Current()->current_zone()->Allocate(len)); |
| 2401 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2401 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2402 const Error& error = Error::Handle( | 2402 const Error& error = Error::Handle( |
| 2403 LanguageError::New(String::Handle(String::New(chars)))); | 2403 LanguageError::New(String::Handle(String::New(chars)))); |
| 2404 Isolate::Current()->long_jump_base()->Jump(1, error); | 2404 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2405 } | 2405 } |
| 2406 | 2406 |
| 2407 | 2407 |
| 2408 } // namespace dart | 2408 } // namespace dart |
| OLD | NEW |