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

Side by Side Diff: src/type-info.cc

Issue 95033003: Move more logic from AST to oracle, pt 3 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years 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 | « src/type-info.h ('k') | src/typing.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 Handle<Object> map_or_code = GetInfo(ast_id); 190 Handle<Object> map_or_code = GetInfo(ast_id);
191 if (map_or_code->IsCode()) { 191 if (map_or_code->IsCode()) {
192 Handle<Code> code = Handle<Code>::cast(map_or_code); 192 Handle<Code> code = Handle<Code>::cast(map_or_code);
193 return code->is_keyed_store_stub() && 193 return code->is_keyed_store_stub() &&
194 code->ic_state() == POLYMORPHIC; 194 code->ic_state() == POLYMORPHIC;
195 } 195 }
196 return false; 196 return false;
197 } 197 }
198 198
199 199
200 bool TypeFeedbackOracle::CallIsMonomorphic(Call* expr) { 200 bool TypeFeedbackOracle::CallIsMonomorphic(TypeFeedbackId id) {
201 Handle<Object> value = GetInfo(expr->CallFeedbackId()); 201 Handle<Object> value = GetInfo(id);
202 return value->IsMap() || value->IsAllocationSite() || value->IsJSFunction() || 202 return value->IsMap() || value->IsAllocationSite() || value->IsJSFunction() ||
203 value->IsSmi() || 203 value->IsSmi() ||
204 (value->IsCode() && Handle<Code>::cast(value)->ic_state() == MONOMORPHIC); 204 (value->IsCode() && Handle<Code>::cast(value)->ic_state() == MONOMORPHIC);
205 } 205 }
206 206
207 207
208 bool TypeFeedbackOracle::KeyedArrayCallIsHoley(Call* expr) { 208 bool TypeFeedbackOracle::KeyedArrayCallIsHoley(TypeFeedbackId id) {
209 Handle<Object> value = GetInfo(expr->CallFeedbackId()); 209 Handle<Object> value = GetInfo(id);
210 Handle<Code> code = Handle<Code>::cast(value); 210 Handle<Code> code = Handle<Code>::cast(value);
211 return KeyedArrayCallStub::IsHoley(code); 211 return KeyedArrayCallStub::IsHoley(code);
212 } 212 }
213 213
214 214
215 bool TypeFeedbackOracle::CallNewIsMonomorphic(CallNew* expr) { 215 bool TypeFeedbackOracle::CallNewIsMonomorphic(TypeFeedbackId id) {
216 Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); 216 Handle<Object> info = GetInfo(id);
217 return info->IsAllocationSite() || info->IsJSFunction(); 217 return info->IsAllocationSite() || info->IsJSFunction();
218 } 218 }
219 219
220 220
221 bool TypeFeedbackOracle::ObjectLiteralStoreIsMonomorphic( 221 bool TypeFeedbackOracle::ObjectLiteralStoreIsMonomorphic(TypeFeedbackId id) {
222 ObjectLiteral::Property* prop) { 222 Handle<Object> map_or_code = GetInfo(id);
223 Handle<Object> map_or_code = GetInfo(prop->key()->LiteralFeedbackId());
224 return map_or_code->IsMap(); 223 return map_or_code->IsMap();
225 } 224 }
226 225
227 226
228 byte TypeFeedbackOracle::ForInType(TypeFeedbackId id) { 227 byte TypeFeedbackOracle::ForInType(TypeFeedbackId id) {
229 Handle<Object> value = GetInfo(id); 228 Handle<Object> value = GetInfo(id);
230 return value->IsSmi() && 229 return value->IsSmi() &&
231 Smi::cast(*value)->value() == TypeFeedbackCells::kForInFastCaseMarker 230 Smi::cast(*value)->value() == TypeFeedbackCells::kForInFastCaseMarker
232 ? ForInStatement::FAST_FOR_IN : ForInStatement::SLOW_FOR_IN; 231 ? ForInStatement::FAST_FOR_IN : ForInStatement::SLOW_FOR_IN;
233 } 232 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 void TypeFeedbackOracle::LoadReceiverTypes(TypeFeedbackId id, 277 void TypeFeedbackOracle::LoadReceiverTypes(TypeFeedbackId id,
279 Handle<String> name, 278 Handle<String> name,
280 SmallMapList* types) { 279 SmallMapList* types) {
281 Code::Flags flags = Code::ComputeFlags( 280 Code::Flags flags = Code::ComputeFlags(
282 Code::HANDLER, MONOMORPHIC, kNoExtraICState, 281 Code::HANDLER, MONOMORPHIC, kNoExtraICState,
283 Code::NORMAL, Code::LOAD_IC); 282 Code::NORMAL, Code::LOAD_IC);
284 CollectReceiverTypes(id, name, flags, types); 283 CollectReceiverTypes(id, name, flags, types);
285 } 284 }
286 285
287 286
288 void TypeFeedbackOracle::StoreReceiverTypes(Assignment* expr, 287 void TypeFeedbackOracle::StoreReceiverTypes(TypeFeedbackId id,
289 Handle<String> name, 288 Handle<String> name,
290 SmallMapList* types) { 289 SmallMapList* types) {
291 Code::Flags flags = Code::ComputeFlags( 290 Code::Flags flags = Code::ComputeFlags(
292 Code::HANDLER, MONOMORPHIC, kNoExtraICState, 291 Code::HANDLER, MONOMORPHIC, kNoExtraICState,
293 Code::NORMAL, Code::STORE_IC); 292 Code::NORMAL, Code::STORE_IC);
294 CollectReceiverTypes(expr->AssignmentFeedbackId(), name, flags, types); 293 CollectReceiverTypes(id, name, flags, types);
295 } 294 }
296 295
297 296
298 void TypeFeedbackOracle::CallReceiverTypes(Call* expr, 297 void TypeFeedbackOracle::CallReceiverTypes(TypeFeedbackId id,
299 Handle<String> name, 298 Handle<String> name,
299 int arity,
300 CallKind call_kind, 300 CallKind call_kind,
301 SmallMapList* types) { 301 SmallMapList* types) {
302 int arity = expr->arguments()->length();
303
304 // Note: Currently we do not take string extra ic data into account 302 // Note: Currently we do not take string extra ic data into account
305 // here. 303 // here.
306 ContextualMode contextual_mode = call_kind == CALL_AS_FUNCTION 304 ContextualMode contextual_mode = call_kind == CALL_AS_FUNCTION
307 ? CONTEXTUAL 305 ? CONTEXTUAL
308 : NOT_CONTEXTUAL; 306 : NOT_CONTEXTUAL;
309 ExtraICState extra_ic_state = 307 ExtraICState extra_ic_state =
310 CallIC::Contextual::encode(contextual_mode); 308 CallIC::Contextual::encode(contextual_mode);
311 309
312 Code::Flags flags = Code::ComputeMonomorphicFlags( 310 Code::Flags flags = Code::ComputeMonomorphicFlags(
313 Code::CALL_IC, extra_ic_state, OWN_MAP, Code::NORMAL, arity); 311 Code::CALL_IC, extra_ic_state, OWN_MAP, Code::NORMAL, arity);
314 CollectReceiverTypes(expr->CallFeedbackId(), name, flags, types); 312 CollectReceiverTypes(id, name, flags, types);
315 } 313 }
316 314
317 315
318 CheckType TypeFeedbackOracle::GetCallCheckType(Call* expr) { 316 CheckType TypeFeedbackOracle::GetCallCheckType(TypeFeedbackId id) {
319 Handle<Object> value = GetInfo(expr->CallFeedbackId()); 317 Handle<Object> value = GetInfo(id);
320 if (!value->IsSmi()) return RECEIVER_MAP_CHECK; 318 if (!value->IsSmi()) return RECEIVER_MAP_CHECK;
321 CheckType check = static_cast<CheckType>(Smi::cast(*value)->value()); 319 CheckType check = static_cast<CheckType>(Smi::cast(*value)->value());
322 ASSERT(check != RECEIVER_MAP_CHECK); 320 ASSERT(check != RECEIVER_MAP_CHECK);
323 return check; 321 return check;
324 } 322 }
325 323
326 324
327 Handle<JSFunction> TypeFeedbackOracle::GetCallTarget(Call* expr) { 325 Handle<JSFunction> TypeFeedbackOracle::GetCallTarget(TypeFeedbackId id) {
328 Handle<Object> info = GetInfo(expr->CallFeedbackId()); 326 Handle<Object> info = GetInfo(id);
329 if (info->IsAllocationSite()) { 327 if (info->IsAllocationSite()) {
330 return Handle<JSFunction>(isolate_->global_context()->array_function()); 328 return Handle<JSFunction>(isolate_->global_context()->array_function());
331 } else { 329 } else {
332 return Handle<JSFunction>::cast(info); 330 return Handle<JSFunction>::cast(info);
333 } 331 }
334 } 332 }
335 333
336 334
337 Handle<JSFunction> TypeFeedbackOracle::GetCallNewTarget(CallNew* expr) { 335 Handle<JSFunction> TypeFeedbackOracle::GetCallNewTarget(TypeFeedbackId id) {
338 Handle<Object> info = GetInfo(expr->CallNewFeedbackId()); 336 Handle<Object> info = GetInfo(id);
339 if (info->IsAllocationSite()) { 337 if (info->IsAllocationSite()) {
340 return Handle<JSFunction>(isolate_->global_context()->array_function()); 338 return Handle<JSFunction>(isolate_->global_context()->array_function());
341 } else { 339 } else {
342 return Handle<JSFunction>::cast(info); 340 return Handle<JSFunction>::cast(info);
343 } 341 }
344 } 342 }
345 343
346 344
347 Handle<Cell> TypeFeedbackOracle::GetCallNewAllocationInfoCell(CallNew* expr) { 345 Handle<Cell> TypeFeedbackOracle::GetCallNewAllocationInfoCell(
348 return GetInfoCell(expr->CallNewFeedbackId()); 346 TypeFeedbackId id) {
347 return GetInfoCell(id);
349 } 348 }
350 349
351 350
352 Handle<Map> TypeFeedbackOracle::GetObjectLiteralStoreMap( 351 Handle<Map> TypeFeedbackOracle::GetObjectLiteralStoreMap(TypeFeedbackId id) {
353 ObjectLiteral::Property* prop) { 352 ASSERT(ObjectLiteralStoreIsMonomorphic(id));
354 ASSERT(ObjectLiteralStoreIsMonomorphic(prop)); 353 return Handle<Map>::cast(GetInfo(id));
355 return Handle<Map>::cast(GetInfo(prop->key()->LiteralFeedbackId()));
356 } 354 }
357 355
358 356
359 bool TypeFeedbackOracle::LoadIsBuiltin( 357 bool TypeFeedbackOracle::LoadIsBuiltin(
360 TypeFeedbackId id, Builtins::Name builtin) { 358 TypeFeedbackId id, Builtins::Name builtin) {
361 return *GetInfo(id) == isolate_->builtins()->builtin(builtin); 359 return *GetInfo(id) == isolate_->builtins()->builtin(builtin);
362 } 360 }
363 361
364 362
365 bool TypeFeedbackOracle::LoadIsStub(TypeFeedbackId id, ICStub* stub) { 363 bool TypeFeedbackOracle::LoadIsStub(TypeFeedbackId id, ICStub* stub) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 *is_string = true; 477 *is_string = true;
480 } else if (LoadIsMonomorphicNormal(id)) { 478 } else if (LoadIsMonomorphicNormal(id)) {
481 receiver_types->Add(LoadMonomorphicReceiverType(id), zone()); 479 receiver_types->Add(LoadMonomorphicReceiverType(id), zone());
482 } else if (LoadIsPolymorphic(id)) { 480 } else if (LoadIsPolymorphic(id)) {
483 receiver_types->Reserve(kMaxKeyedPolymorphism, zone()); 481 receiver_types->Reserve(kMaxKeyedPolymorphism, zone());
484 CollectKeyedReceiverTypes(id, receiver_types); 482 CollectKeyedReceiverTypes(id, receiver_types);
485 } 483 }
486 } 484 }
487 485
488 486
487 void TypeFeedbackOracle::AssignmentReceiverTypes(
488 TypeFeedbackId id, Handle<String> name, SmallMapList* receiver_types) {
489 receiver_types->Clear();
490 StoreReceiverTypes(id, name, receiver_types);
491 }
492
493
494 void TypeFeedbackOracle::KeyedAssignmentReceiverTypes(
495 TypeFeedbackId id, SmallMapList* receiver_types,
496 KeyedAccessStoreMode* store_mode) {
497 receiver_types->Clear();
498 if (StoreIsMonomorphicNormal(id)) {
499 // Record receiver type for monomorphic keyed stores.
500 receiver_types->Add(StoreMonomorphicReceiverType(id), zone());
501 } else if (StoreIsKeyedPolymorphic(id)) {
502 receiver_types->Reserve(kMaxKeyedPolymorphism, zone());
503 CollectKeyedReceiverTypes(id, receiver_types);
504 }
505 *store_mode = GetStoreMode(id);
506 }
507
508
489 void TypeFeedbackOracle::CountReceiverTypes( 509 void TypeFeedbackOracle::CountReceiverTypes(
490 TypeFeedbackId id, SmallMapList* receiver_types) { 510 TypeFeedbackId id, SmallMapList* receiver_types) {
491 receiver_types->Clear(); 511 receiver_types->Clear();
492 if (StoreIsMonomorphicNormal(id)) { 512 if (StoreIsMonomorphicNormal(id)) {
493 // Record receiver type for monomorphic keyed stores. 513 // Record receiver type for monomorphic keyed stores.
494 receiver_types->Add(StoreMonomorphicReceiverType(id), zone()); 514 receiver_types->Add(StoreMonomorphicReceiverType(id), zone());
495 } else if (StoreIsKeyedPolymorphic(id)) { 515 } else if (StoreIsKeyedPolymorphic(id)) {
496 receiver_types->Reserve(kMaxKeyedPolymorphism, zone()); 516 receiver_types->Reserve(kMaxKeyedPolymorphism, zone());
497 CollectKeyedReceiverTypes(id, receiver_types); 517 CollectKeyedReceiverTypes(id, receiver_types);
498 } else { 518 } else {
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 if (info.IsUninitialized()) return Representation::None(); 764 if (info.IsUninitialized()) return Representation::None();
745 if (info.IsSmi()) return Representation::Smi(); 765 if (info.IsSmi()) return Representation::Smi();
746 if (info.IsInteger32()) return Representation::Integer32(); 766 if (info.IsInteger32()) return Representation::Integer32();
747 if (info.IsDouble()) return Representation::Double(); 767 if (info.IsDouble()) return Representation::Double();
748 if (info.IsNumber()) return Representation::Double(); 768 if (info.IsNumber()) return Representation::Double();
749 return Representation::Tagged(); 769 return Representation::Tagged();
750 } 770 }
751 771
752 772
753 } } // namespace v8::internal 773 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/type-info.h ('k') | src/typing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698