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

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

Issue 15743017: Adds a flag to the standalone vm to throw an exception on 53-bit integer overflow. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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/intrinsifier.h ('k') | runtime/vm/object.cc » ('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 // Class for intrinsifying functions. 4 // Class for intrinsifying functions.
5 5
6 #include "vm/intrinsifier.h" 6 #include "vm/intrinsifier.h"
7 #include "vm/flags.h" 7 #include "vm/flags.h"
8 #include "vm/object.h" 8 #include "vm/object.h"
9 #include "vm/symbols.h" 9 #include "vm/symbols.h"
10 10
11 namespace dart { 11 namespace dart {
12 12
13 DEFINE_FLAG(bool, intrinsify, true, "Instrinsify when possible"); 13 DEFINE_FLAG(bool, intrinsify, true, "Instrinsify when possible");
14 14 DECLARE_FLAG(bool, throw_on_javascript_int_overflow);
15 15
16 static bool CompareNames(const Library& lib, 16 static bool CompareNames(const Library& lib,
17 const char* test_name, 17 const char* test_name,
18 const char* name) { 18 const char* name) {
19 static const char* kPrivateGetterPrefix = "get:_"; 19 static const char* kPrivateGetterPrefix = "get:_";
20 static const char* kPrivateSetterPrefix = "set:_"; 20 static const char* kPrivateSetterPrefix = "set:_";
21 21
22 if (test_name[0] == '_') { 22 if (test_name[0] == '_') {
23 if (name[0] != '_') { 23 if (name[0] != '_') {
24 return false; 24 return false;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 91 }
92 92
93 93
94 void Intrinsifier::InitializeState() { 94 void Intrinsifier::InitializeState() {
95 Isolate* isolate = Isolate::Current(); 95 Isolate* isolate = Isolate::Current();
96 Library& lib = Library::Handle(isolate); 96 Library& lib = Library::Handle(isolate);
97 Class& cls = Class::Handle(isolate); 97 Class& cls = Class::Handle(isolate);
98 Function& func = Function::Handle(isolate); 98 Function& func = Function::Handle(isolate);
99 String& str = String::Handle(isolate); 99 String& str = String::Handle(isolate);
100 Error& error = Error::Handle(isolate); 100 Error& error = Error::Handle(isolate);
101 bool set_intrinsic = true;
101 102
102 #define SETUP_FUNCTION(class_name, function_name, destination, fp) \ 103 #define SETUP_FUNCTION(class_name, function_name, destination, fp) \
103 if (strcmp(#class_name, "::") == 0) { \ 104 if (strcmp(#class_name, "::") == 0) { \
104 str = String::New(#function_name); \ 105 str = String::New(#function_name); \
105 func = lib.LookupFunctionAllowPrivate(str); \ 106 func = lib.LookupFunctionAllowPrivate(str); \
106 } else { \ 107 } else { \
107 str = String::New(#class_name); \ 108 str = String::New(#class_name); \
108 cls = lib.LookupClassAllowPrivate(str); \ 109 cls = lib.LookupClassAllowPrivate(str); \
109 ASSERT(!cls.IsNull()); \ 110 ASSERT(!cls.IsNull()); \
110 error = cls.EnsureIsFinalized(isolate); \ 111 error = cls.EnsureIsFinalized(isolate); \
111 ASSERT(error.IsNull()); \ 112 ASSERT(error.IsNull()); \
112 if (#function_name[0] == '.') { \ 113 if (#function_name[0] == '.') { \
113 str = String::New(#class_name#function_name); \ 114 str = String::New(#class_name#function_name); \
114 } else { \ 115 } else { \
115 str = String::New(#function_name); \ 116 str = String::New(#function_name); \
116 } \ 117 } \
117 func = cls.LookupFunctionAllowPrivate(str); \ 118 func = cls.LookupFunctionAllowPrivate(str); \
118 } \ 119 } \
119 ASSERT(!func.IsNull()); \ 120 ASSERT(!func.IsNull()); \
120 func.set_is_intrinsic(true); \ 121 func.set_is_intrinsic(set_intrinsic); \
121 122
122 // Set up all core lib functions that can be intrisified. 123 // Set up all core lib functions that can be intrisified.
123 lib = Library::CoreLibrary(); 124 lib = Library::CoreLibrary();
124 CORE_LIB_INTRINSIC_LIST(SETUP_FUNCTION); 125 CORE_LIB_INTRINSIC_LIST(SETUP_FUNCTION);
125 126
127 // Integer intrinsics are in the core library, but we don't want to intrinsify
128 // if we are looking for javascript integer overflow.
129 set_intrinsic = !FLAG_throw_on_javascript_int_overflow;
130 CORE_INTEGER_LIB_INTRINSIC_LIST(SETUP_FUNCTION);
131 set_intrinsic = true;
132
126 // Set up all math lib functions that can be intrisified. 133 // Set up all math lib functions that can be intrisified.
127 lib = Library::MathLibrary(); 134 lib = Library::MathLibrary();
128 MATH_LIB_INTRINSIC_LIST(SETUP_FUNCTION); 135 MATH_LIB_INTRINSIC_LIST(SETUP_FUNCTION);
129 136
130 // Set up all dart:typed_data lib functions that can be intrisified. 137 // Set up all dart:typed_data lib functions that can be intrisified.
131 lib = Library::TypedDataLibrary(); 138 lib = Library::TypedDataLibrary();
132 TYPED_DATA_LIB_INTRINSIC_LIST(SETUP_FUNCTION); 139 TYPED_DATA_LIB_INTRINSIC_LIST(SETUP_FUNCTION);
133 140
134 #undef SETUP_FUNCTION 141 #undef SETUP_FUNCTION
135 } 142 }
(...skipping 10 matching lines...) Expand all
146 #define FIND_INTRINSICS(test_class_name, test_function_name, destination, fp) \ 153 #define FIND_INTRINSICS(test_class_name, test_function_name, destination, fp) \
147 if (TestFunction(lib, function, \ 154 if (TestFunction(lib, function, \
148 class_name, function_name, \ 155 class_name, function_name, \
149 #test_class_name, #test_function_name)) { \ 156 #test_class_name, #test_function_name)) { \
150 ASSERT(function.CheckSourceFingerprint(fp)); \ 157 ASSERT(function.CheckSourceFingerprint(fp)); \
151 return destination(assembler); \ 158 return destination(assembler); \
152 } \ 159 } \
153 160
154 if (lib.raw() == Library::CoreLibrary()) { 161 if (lib.raw() == Library::CoreLibrary()) {
155 CORE_LIB_INTRINSIC_LIST(FIND_INTRINSICS); 162 CORE_LIB_INTRINSIC_LIST(FIND_INTRINSICS);
163 CORE_INTEGER_LIB_INTRINSIC_LIST(FIND_INTRINSICS);
156 } else if (lib.raw() == Library::TypedDataLibrary()) { 164 } else if (lib.raw() == Library::TypedDataLibrary()) {
157 TYPED_DATA_LIB_INTRINSIC_LIST(FIND_INTRINSICS); 165 TYPED_DATA_LIB_INTRINSIC_LIST(FIND_INTRINSICS);
158 } else if (lib.raw() == Library::MathLibrary()) { 166 } else if (lib.raw() == Library::MathLibrary()) {
159 MATH_LIB_INTRINSIC_LIST(FIND_INTRINSICS); 167 MATH_LIB_INTRINSIC_LIST(FIND_INTRINSICS);
160 } 168 }
161 return false; 169 return false;
162 170
163 #undef FIND_INTRINSICS 171 #undef FIND_INTRINSICS
164 } 172 }
165 173
166 } // namespace dart 174 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698