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

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

Issue 979323005: Refactor TypeFeedbackOracle to accept Handle<Name> instead of Handle<String>. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/type-info.h ('k') | no next file » | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/ast.h" 7 #include "src/ast.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/ic/ic.h" 10 #include "src/ic/ic.h"
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 Handle<Object> object = GetInfo(id); 306 Handle<Object> object = GetInfo(id);
307 if (!object->IsCode()) return Type::None(zone()); 307 if (!object->IsCode()) return Type::None(zone());
308 Handle<Code> code = Handle<Code>::cast(object); 308 Handle<Code> code = Handle<Code>::cast(object);
309 DCHECK_EQ(Code::BINARY_OP_IC, code->kind()); 309 DCHECK_EQ(Code::BINARY_OP_IC, code->kind());
310 BinaryOpICState state(isolate(), code->extra_ic_state()); 310 BinaryOpICState state(isolate(), code->extra_ic_state());
311 return state.GetLeftType(zone()); 311 return state.GetLeftType(zone());
312 } 312 }
313 313
314 314
315 void TypeFeedbackOracle::PropertyReceiverTypes(TypeFeedbackId id, 315 void TypeFeedbackOracle::PropertyReceiverTypes(TypeFeedbackId id,
316 Handle<String> name, 316 Handle<Name> name,
317 SmallMapList* receiver_types) { 317 SmallMapList* receiver_types) {
318 receiver_types->Clear(); 318 receiver_types->Clear();
319 Code::Flags flags = Code::ComputeHandlerFlags(Code::LOAD_IC); 319 Code::Flags flags = Code::ComputeHandlerFlags(Code::LOAD_IC);
320 CollectReceiverTypes(id, name, flags, receiver_types); 320 CollectReceiverTypes(id, name, flags, receiver_types);
321 } 321 }
322 322
323 323
324 bool TypeFeedbackOracle::HasOnlyStringMaps(SmallMapList* receiver_types) { 324 bool TypeFeedbackOracle::HasOnlyStringMaps(SmallMapList* receiver_types) {
325 bool all_strings = receiver_types->length() > 0; 325 bool all_strings = receiver_types->length() > 0;
326 for (int i = 0; i < receiver_types->length(); i++) { 326 for (int i = 0; i < receiver_types->length(); i++) {
327 all_strings &= receiver_types->at(i)->IsStringMap(); 327 all_strings &= receiver_types->at(i)->IsStringMap();
328 } 328 }
329 return all_strings; 329 return all_strings;
330 } 330 }
331 331
332 332
333 void TypeFeedbackOracle::KeyedPropertyReceiverTypes( 333 void TypeFeedbackOracle::KeyedPropertyReceiverTypes(
334 TypeFeedbackId id, 334 TypeFeedbackId id,
335 SmallMapList* receiver_types, 335 SmallMapList* receiver_types,
336 bool* is_string, 336 bool* is_string,
337 IcCheckType* key_type) { 337 IcCheckType* key_type) {
338 receiver_types->Clear(); 338 receiver_types->Clear();
339 CollectReceiverTypes(id, receiver_types); 339 CollectReceiverTypes(id, receiver_types);
340 *is_string = HasOnlyStringMaps(receiver_types); 340 *is_string = HasOnlyStringMaps(receiver_types);
341 GetLoadKeyType(id, key_type); 341 GetLoadKeyType(id, key_type);
342 } 342 }
343 343
344 344
345 void TypeFeedbackOracle::PropertyReceiverTypes(FeedbackVectorICSlot slot, 345 void TypeFeedbackOracle::PropertyReceiverTypes(FeedbackVectorICSlot slot,
346 Handle<String> name, 346 Handle<Name> name,
347 SmallMapList* receiver_types) { 347 SmallMapList* receiver_types) {
348 receiver_types->Clear(); 348 receiver_types->Clear();
349 LoadICNexus nexus(feedback_vector_, slot); 349 LoadICNexus nexus(feedback_vector_, slot);
350 Code::Flags flags = Code::ComputeHandlerFlags(Code::LOAD_IC); 350 Code::Flags flags = Code::ComputeHandlerFlags(Code::LOAD_IC);
351 CollectReceiverTypes(&nexus, name, flags, receiver_types); 351 CollectReceiverTypes(&nexus, name, flags, receiver_types);
352 } 352 }
353 353
354 354
355 void TypeFeedbackOracle::KeyedPropertyReceiverTypes( 355 void TypeFeedbackOracle::KeyedPropertyReceiverTypes(
356 FeedbackVectorICSlot slot, SmallMapList* receiver_types, bool* is_string, 356 FeedbackVectorICSlot slot, SmallMapList* receiver_types, bool* is_string,
357 IcCheckType* key_type) { 357 IcCheckType* key_type) {
358 receiver_types->Clear(); 358 receiver_types->Clear();
359 KeyedLoadICNexus nexus(feedback_vector_, slot); 359 KeyedLoadICNexus nexus(feedback_vector_, slot);
360 CollectReceiverTypes<FeedbackNexus>(&nexus, receiver_types); 360 CollectReceiverTypes<FeedbackNexus>(&nexus, receiver_types);
361 *is_string = HasOnlyStringMaps(receiver_types); 361 *is_string = HasOnlyStringMaps(receiver_types);
362 *key_type = nexus.FindFirstName() != NULL ? PROPERTY : ELEMENT; 362 *key_type = nexus.FindFirstName() != NULL ? PROPERTY : ELEMENT;
363 } 363 }
364 364
365 365
366 void TypeFeedbackOracle::AssignmentReceiverTypes( 366 void TypeFeedbackOracle::AssignmentReceiverTypes(TypeFeedbackId id,
367 TypeFeedbackId id, Handle<String> name, SmallMapList* receiver_types) { 367 Handle<Name> name,
368 SmallMapList* receiver_types) {
368 receiver_types->Clear(); 369 receiver_types->Clear();
369 Code::Flags flags = Code::ComputeHandlerFlags(Code::STORE_IC); 370 Code::Flags flags = Code::ComputeHandlerFlags(Code::STORE_IC);
370 CollectReceiverTypes(id, name, flags, receiver_types); 371 CollectReceiverTypes(id, name, flags, receiver_types);
371 } 372 }
372 373
373 374
374 void TypeFeedbackOracle::KeyedAssignmentReceiverTypes( 375 void TypeFeedbackOracle::KeyedAssignmentReceiverTypes(
375 TypeFeedbackId id, SmallMapList* receiver_types, 376 TypeFeedbackId id, SmallMapList* receiver_types,
376 KeyedAccessStoreMode* store_mode, IcCheckType* key_type) { 377 KeyedAccessStoreMode* store_mode, IcCheckType* key_type) {
377 receiver_types->Clear(); 378 receiver_types->Clear();
378 CollectReceiverTypes(id, receiver_types); 379 CollectReceiverTypes(id, receiver_types);
379 GetStoreModeAndKeyType(id, store_mode, key_type); 380 GetStoreModeAndKeyType(id, store_mode, key_type);
380 } 381 }
381 382
382 383
383 void TypeFeedbackOracle::CountReceiverTypes(TypeFeedbackId id, 384 void TypeFeedbackOracle::CountReceiverTypes(TypeFeedbackId id,
384 SmallMapList* receiver_types) { 385 SmallMapList* receiver_types) {
385 receiver_types->Clear(); 386 receiver_types->Clear();
386 CollectReceiverTypes(id, receiver_types); 387 CollectReceiverTypes(id, receiver_types);
387 } 388 }
388 389
389 390
390 void TypeFeedbackOracle::CollectReceiverTypes(TypeFeedbackId ast_id, 391 void TypeFeedbackOracle::CollectReceiverTypes(TypeFeedbackId ast_id,
391 Handle<String> name, 392 Handle<Name> name,
392 Code::Flags flags, 393 Code::Flags flags,
393 SmallMapList* types) { 394 SmallMapList* types) {
394 Handle<Object> object = GetInfo(ast_id); 395 Handle<Object> object = GetInfo(ast_id);
395 if (object->IsUndefined() || object->IsSmi()) return; 396 if (object->IsUndefined() || object->IsSmi()) return;
396 397
397 DCHECK(object->IsCode()); 398 DCHECK(object->IsCode());
398 Handle<Code> code(Handle<Code>::cast(object)); 399 Handle<Code> code(Handle<Code>::cast(object));
399 CollectReceiverTypes<Code>(*code, name, flags, types); 400 CollectReceiverTypes<Code>(*code, name, flags, types);
400 } 401 }
401 402
402 403
403 template <class T> 404 template <class T>
404 void TypeFeedbackOracle::CollectReceiverTypes(T* obj, Handle<String> name, 405 void TypeFeedbackOracle::CollectReceiverTypes(T* obj, Handle<Name> name,
405 Code::Flags flags, 406 Code::Flags flags,
406 SmallMapList* types) { 407 SmallMapList* types) {
407 if (FLAG_collect_megamorphic_maps_from_stub_cache && 408 if (FLAG_collect_megamorphic_maps_from_stub_cache &&
408 obj->ic_state() == MEGAMORPHIC) { 409 obj->ic_state() == MEGAMORPHIC) {
409 types->Reserve(4, zone()); 410 types->Reserve(4, zone());
410 isolate()->stub_cache()->CollectMatchingMaps( 411 isolate()->stub_cache()->CollectMatchingMaps(
411 types, name, flags, native_context_, zone()); 412 types, name, flags, native_context_, zone());
412 } else { 413 } else {
413 CollectReceiverTypes<T>(obj, types); 414 CollectReceiverTypes<T>(obj, types);
414 } 415 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 UnseededNumberDictionary::kNotFound); 563 UnseededNumberDictionary::kNotFound);
563 // Dictionary has been allocated with sufficient size for all elements. 564 // Dictionary has been allocated with sufficient size for all elements.
564 DisallowHeapAllocation no_need_to_resize_dictionary; 565 DisallowHeapAllocation no_need_to_resize_dictionary;
565 HandleScope scope(isolate()); 566 HandleScope scope(isolate());
566 USE(UnseededNumberDictionary::AtNumberPut( 567 USE(UnseededNumberDictionary::AtNumberPut(
567 dictionary_, IdToKey(ast_id), handle(target, isolate()))); 568 dictionary_, IdToKey(ast_id), handle(target, isolate())));
568 } 569 }
569 570
570 571
571 } } // namespace v8::internal 572 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/type-info.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698