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 "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "vm/ast_printer.h" | 8 #include "vm/ast_printer.h" |
| 9 #include "vm/bit_vector.h" | 9 #include "vm/bit_vector.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 | 32 |
| 33 DEFINE_FLAG(bool, eliminate_type_checks, true, | 33 DEFINE_FLAG(bool, eliminate_type_checks, true, |
| 34 "Eliminate type checks when allowed by static type analysis."); | 34 "Eliminate type checks when allowed by static type analysis."); |
| 35 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); | 35 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); |
| 36 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); | 36 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); |
| 37 DEFINE_FLAG(bool, trace_type_check_elimination, false, | 37 DEFINE_FLAG(bool, trace_type_check_elimination, false, |
| 38 "Trace type check elimination at compile time."); | 38 "Trace type check elimination at compile time."); |
| 39 DECLARE_FLAG(bool, enable_type_checks); | 39 DECLARE_FLAG(bool, enable_type_checks); |
| 40 | 40 |
| 41 | 41 |
| 42 | |
| 43 // TODO(srdjan): Allow compiler to add constants as they are encountered in | |
| 44 // the compilation. | |
| 45 const double kCommonDoubleConstants[15] = | |
| 46 {-1.0, -0.5, -0.1, 0.0, 0.1, 0.5, 1.0, 2.0, 4.0, 5.0, | |
| 47 10.0, 20.0, 30.0, 64.0, 255.0}; | |
|
zra
2014/05/01 18:34:14
PI? e?
srdjan
2014/05/01 20:33:04
Added all math constant and NaN as well.
| |
| 48 | |
| 49 uword FlowGraphBuilder::FindDoubleConstant(double value) { | |
| 50 intptr_t len = sizeof(kCommonDoubleConstants) / sizeof(double); // NOLINT | |
| 51 for (intptr_t i = 0; i < len; i++) { | |
| 52 // Bitwise compare. | |
| 53 if (*reinterpret_cast<int64_t*>(&value) == | |
| 54 *reinterpret_cast<const int64_t*>(&kCommonDoubleConstants[i])) { | |
| 55 return reinterpret_cast<uword>(&kCommonDoubleConstants[i]); | |
| 56 } | |
| 57 } | |
| 58 return 0; | |
| 59 } | |
| 60 | |
|
zra
2014/05/01 18:34:14
Missing \n
srdjan
2014/05/01 20:33:04
Done.
| |
| 42 // Base class for a stack of enclosing statements of interest (e.g., | 61 // Base class for a stack of enclosing statements of interest (e.g., |
| 43 // blocks (breakable) and loops (continuable)). | 62 // blocks (breakable) and loops (continuable)). |
| 44 class NestedStatement : public ValueObject { | 63 class NestedStatement : public ValueObject { |
| 45 public: | 64 public: |
| 46 FlowGraphBuilder* owner() const { return owner_; } | 65 FlowGraphBuilder* owner() const { return owner_; } |
| 47 const SourceLabel* label() const { return label_; } | 66 const SourceLabel* label() const { return label_; } |
| 48 NestedStatement* outer() const { return outer_; } | 67 NestedStatement* outer() const { return outer_; } |
| 49 JoinEntryInstr* break_target() const { return break_target_; } | 68 JoinEntryInstr* break_target() const { return break_target_; } |
| 50 | 69 |
| 51 virtual intptr_t ContextLevel() const; | 70 virtual intptr_t ContextLevel() const; |
| (...skipping 3847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3899 function.token_pos(), | 3918 function.token_pos(), |
| 3900 LanguageError::kError, | 3919 LanguageError::kError, |
| 3901 Heap::kNew, | 3920 Heap::kNew, |
| 3902 "FlowGraphBuilder Bailout: %s %s", | 3921 "FlowGraphBuilder Bailout: %s %s", |
| 3903 String::Handle(function.name()).ToCString(), | 3922 String::Handle(function.name()).ToCString(), |
| 3904 reason)); | 3923 reason)); |
| 3905 Isolate::Current()->long_jump_base()->Jump(1, error); | 3924 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3906 } | 3925 } |
| 3907 | 3926 |
| 3908 } // namespace dart | 3927 } // namespace dart |
| OLD | NEW |