OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/ic/ic.h" | 7 #include "src/ic/ic.h" |
8 #include "src/ic/ic-state.h" | 8 #include "src/ic/ic-state.h" |
9 #include "src/objects.h" | 9 #include "src/objects.h" |
10 #include "src/type-feedback-vector-inl.h" | 10 #include "src/type-feedback-vector-inl.h" |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 if (feedback->IsFixedArray() || feedback->IsString()) { | 428 if (feedback->IsFixedArray() || feedback->IsString()) { |
429 int found = 0; | 429 int found = 0; |
430 if (feedback->IsString()) { | 430 if (feedback->IsString()) { |
431 feedback = GetFeedbackExtra(); | 431 feedback = GetFeedbackExtra(); |
432 } | 432 } |
433 FixedArray* array = FixedArray::cast(feedback); | 433 FixedArray* array = FixedArray::cast(feedback); |
434 // The array should be of the form [<optional name>], then | 434 // The array should be of the form [<optional name>], then |
435 // [map, handler, map, handler, ... ] | 435 // [map, handler, map, handler, ... ] |
436 DCHECK(array->length() >= 2); | 436 DCHECK(array->length() >= 2); |
437 for (int i = 0; i < array->length(); i += 2) { | 437 for (int i = 0; i < array->length(); i += 2) { |
| 438 DCHECK(array->get(i)->IsWeakCell()); |
438 WeakCell* cell = WeakCell::cast(array->get(i)); | 439 WeakCell* cell = WeakCell::cast(array->get(i)); |
439 if (!cell->cleared()) { | 440 if (!cell->cleared()) { |
440 Map* map = Map::cast(cell->value()); | 441 Map* map = Map::cast(cell->value()); |
441 maps->Add(handle(map, isolate)); | 442 maps->Add(handle(map, isolate)); |
442 found++; | 443 found++; |
443 } | 444 } |
444 } | 445 } |
445 return found; | 446 return found; |
446 } else if (feedback->IsWeakCell()) { | 447 } else if (feedback->IsWeakCell()) { |
447 WeakCell* cell = WeakCell::cast(feedback); | 448 WeakCell* cell = WeakCell::cast(feedback); |
448 if (!cell->cleared()) { | 449 if (!cell->cleared()) { |
449 Map* map = Map::cast(cell->value()); | 450 Map* map = Map::cast(cell->value()); |
450 maps->Add(handle(map, isolate)); | 451 maps->Add(handle(map, isolate)); |
451 return 1; | 452 return 1; |
452 } | 453 } |
453 } | 454 } |
454 | 455 |
455 return 0; | 456 return 0; |
456 } | 457 } |
457 | 458 |
458 | 459 |
459 MaybeHandle<Code> FeedbackNexus::FindHandlerForMap(Handle<Map> map) const { | 460 MaybeHandle<Code> FeedbackNexus::FindHandlerForMap(Handle<Map> map) const { |
460 Object* feedback = GetFeedback(); | 461 Object* feedback = GetFeedback(); |
461 if (feedback->IsFixedArray() || feedback->IsString()) { | 462 if (feedback->IsFixedArray() || feedback->IsString()) { |
462 if (feedback->IsString()) { | 463 if (feedback->IsString()) { |
463 feedback = GetFeedbackExtra(); | 464 feedback = GetFeedbackExtra(); |
464 } | 465 } |
465 FixedArray* array = FixedArray::cast(feedback); | 466 FixedArray* array = FixedArray::cast(feedback); |
466 for (int i = 0; i < array->length(); i += 2) { | 467 for (int i = 0; i < array->length(); i += 2) { |
| 468 DCHECK(array->get(i)->IsWeakCell()); |
467 WeakCell* cell = WeakCell::cast(array->get(i)); | 469 WeakCell* cell = WeakCell::cast(array->get(i)); |
468 if (!cell->cleared()) { | 470 if (!cell->cleared()) { |
469 Map* array_map = Map::cast(cell->value()); | 471 Map* array_map = Map::cast(cell->value()); |
470 if (array_map == *map) { | 472 if (array_map == *map) { |
471 Code* code = Code::cast(array->get(i + 1)); | 473 Code* code = Code::cast(array->get(i + 1)); |
472 DCHECK(code->kind() == Code::HANDLER); | 474 DCHECK(code->kind() == Code::HANDLER); |
473 return handle(code); | 475 return handle(code); |
474 } | 476 } |
475 } | 477 } |
476 } | 478 } |
(...skipping 18 matching lines...) Expand all Loading... |
495 int count = 0; | 497 int count = 0; |
496 if (feedback->IsFixedArray() || feedback->IsString()) { | 498 if (feedback->IsFixedArray() || feedback->IsString()) { |
497 if (feedback->IsString()) { | 499 if (feedback->IsString()) { |
498 feedback = GetFeedbackExtra(); | 500 feedback = GetFeedbackExtra(); |
499 } | 501 } |
500 FixedArray* array = FixedArray::cast(feedback); | 502 FixedArray* array = FixedArray::cast(feedback); |
501 // The array should be of the form [map, handler, map, handler, ... ]. | 503 // The array should be of the form [map, handler, map, handler, ... ]. |
502 // Be sure to skip handlers whose maps have been cleared. | 504 // Be sure to skip handlers whose maps have been cleared. |
503 DCHECK(array->length() >= 2); | 505 DCHECK(array->length() >= 2); |
504 for (int i = 0; i < array->length(); i += 2) { | 506 for (int i = 0; i < array->length(); i += 2) { |
| 507 DCHECK(array->get(i)->IsWeakCell()); |
505 WeakCell* cell = WeakCell::cast(array->get(i)); | 508 WeakCell* cell = WeakCell::cast(array->get(i)); |
506 if (!cell->cleared()) { | 509 if (!cell->cleared()) { |
507 Code* code = Code::cast(array->get(i + 1)); | 510 Code* code = Code::cast(array->get(i + 1)); |
508 DCHECK(code->kind() == Code::HANDLER); | 511 DCHECK(code->kind() == Code::HANDLER); |
509 code_list->Add(handle(code)); | 512 code_list->Add(handle(code)); |
510 count++; | 513 count++; |
511 } | 514 } |
512 } | 515 } |
513 } else if (feedback->IsWeakCell()) { | 516 } else if (feedback->IsWeakCell()) { |
514 WeakCell* cell = WeakCell::cast(feedback); | 517 WeakCell* cell = WeakCell::cast(feedback); |
(...skipping 18 matching lines...) Expand all Loading... |
533 | 536 |
534 Name* KeyedLoadICNexus::FindFirstName() const { | 537 Name* KeyedLoadICNexus::FindFirstName() const { |
535 Object* feedback = GetFeedback(); | 538 Object* feedback = GetFeedback(); |
536 if (feedback->IsString()) { | 539 if (feedback->IsString()) { |
537 return Name::cast(feedback); | 540 return Name::cast(feedback); |
538 } | 541 } |
539 return NULL; | 542 return NULL; |
540 } | 543 } |
541 } | 544 } |
542 } // namespace v8::internal | 545 } // namespace v8::internal |
OLD | NEW |