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

Side by Side Diff: vm/code_generator.cc

Issue 9580036: - Always write a Null Object for Code objects (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 9 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 | « no previous file | vm/dart_api_impl.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/code_generator.h" 5 #include "vm/code_generator.h"
6 6
7 #include "vm/code_index_table.h" 7 #include "vm/code_index_table.h"
8 #include "vm/code_patcher.h" 8 #include "vm/code_patcher.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 Smi::Handle(Smi::New(num_arguments))); 1129 Smi::Handle(Smi::New(num_arguments)));
1130 cache.SetAt(i + FunctionsCache::kNamedArgCount, 1130 cache.SetAt(i + FunctionsCache::kNamedArgCount,
1131 Smi::Handle(Smi::New(num_named_arguments))); 1131 Smi::Handle(Smi::New(num_named_arguments)));
1132 cache.SetAt(i + FunctionsCache::kFunction, function); 1132 cache.SetAt(i + FunctionsCache::kFunction, function);
1133 } 1133 }
1134 1134
1135 1135
1136 void FunctionsCache::AddCompiledFunction(const Function& function, 1136 void FunctionsCache::AddCompiledFunction(const Function& function,
1137 int num_arguments, 1137 int num_arguments,
1138 int num_named_arguments) { 1138 int num_named_arguments) {
1139 // TODO(srdjan): Evaluate if populating the function cache is needed.
1140 // It is turned off currently because we do not populate code objects
1141 // in snapshot and hence end up in an inconsistent state as function
1142 // cache is populated but there are no code objects.
1143 #if 0
1139 ASSERT(function.HasCode()); 1144 ASSERT(function.HasCode());
1140 Array& cache = Array::Handle(class_.functions_cache()); 1145 Array& cache = Array::Handle(class_.functions_cache());
1141 // Search for first free slot. Last entry is always NULL object. 1146 // Search for first free slot. Last entry is always NULL object.
1142 for (intptr_t i = 0; i < (cache.Length() - kNumEntries); i += kNumEntries) { 1147 for (intptr_t i = 0; i < (cache.Length() - kNumEntries); i += kNumEntries) {
1143 if (Object::Handle(cache.At(i)).IsNull()) { 1148 if (Object::Handle(cache.At(i)).IsNull()) {
1144 EnterFunctionAt(i, 1149 EnterFunctionAt(i,
1145 cache, 1150 cache,
1146 function, 1151 function,
1147 num_arguments, 1152 num_arguments,
1148 num_named_arguments); 1153 num_named_arguments);
1149 return; 1154 return;
1150 } 1155 }
1151 } 1156 }
1152 intptr_t ix = cache.Length() - kNumEntries; 1157 intptr_t ix = cache.Length() - kNumEntries;
1153 // Grow by 8 entries. 1158 // Grow by 8 entries.
1154 cache = Array::Grow(cache, cache.Length() + (8 * kNumEntries)); 1159 cache = Array::Grow(cache, cache.Length() + (8 * kNumEntries));
1155 class_.set_functions_cache(cache); 1160 class_.set_functions_cache(cache);
1156 EnterFunctionAt(ix, 1161 EnterFunctionAt(ix,
1157 cache, 1162 cache,
1158 function, 1163 function,
1159 num_arguments, 1164 num_arguments,
1160 num_named_arguments); 1165 num_named_arguments);
1166 #endif
1161 } 1167 }
1162 1168
1163 1169
1164 // Only the number of named arguments is checked, but not the actual names. 1170 // Only the number of named arguments is checked, but not the actual names.
1165 RawCode* FunctionsCache::LookupCode(const String& function_name, 1171 RawCode* FunctionsCache::LookupCode(const String& function_name,
1166 int num_arguments, 1172 int num_arguments,
1167 int num_named_arguments) { 1173 int num_named_arguments) {
1168 const Array& cache = Array::Handle(class_.functions_cache()); 1174 const Array& cache = Array::Handle(class_.functions_cache());
1169 String& test_name = String::Handle(); 1175 String& test_name = String::Handle();
1170 for (intptr_t i = 0; i < cache.Length(); i += kNumEntries) { 1176 for (intptr_t i = 0; i < cache.Length(); i += kNumEntries) {
(...skipping 17 matching lines...) Expand all
1188 } 1194 }
1189 } 1195 }
1190 } 1196 }
1191 // The cache is null terminated, therefore the loop above should never 1197 // The cache is null terminated, therefore the loop above should never
1192 // terminate by itself. 1198 // terminate by itself.
1193 UNREACHABLE(); 1199 UNREACHABLE();
1194 return Code::null(); 1200 return Code::null();
1195 } 1201 }
1196 1202
1197 } // namespace dart 1203 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698