OLD | NEW |
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/isolate.h" | 5 #include "src/isolate.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <fstream> // NOLINT(readability/streams) | 9 #include <fstream> // NOLINT(readability/streams) |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 2493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2504 if (!iter.IsAtEnd()) { | 2504 if (!iter.IsAtEnd()) { |
2505 DCHECK_EQ(false, cell_reports_intact); | 2505 DCHECK_EQ(false, cell_reports_intact); |
2506 return cell_reports_intact; | 2506 return cell_reports_intact; |
2507 } | 2507 } |
2508 | 2508 |
2509 #endif | 2509 #endif |
2510 | 2510 |
2511 return cell_reports_intact; | 2511 return cell_reports_intact; |
2512 } | 2512 } |
2513 | 2513 |
| 2514 bool Isolate::IsArraySpeciesLookupChainIntact() { |
| 2515 // Note: It would be nice to have debug checks to make sure that the |
| 2516 // species protector is accurate, but this would be hard to do for most of |
| 2517 // what the protector stands for: |
| 2518 // - You'd need to traverse the heap to check that no Array instance has |
| 2519 // a constructor property or a modified __proto__ |
| 2520 // - To check that Array[Symbol.species] == Array, JS code has to execute, |
| 2521 // but JS cannot be invoked in callstack overflow situations |
| 2522 // All that could be checked reliably is that |
| 2523 // Array.prototype.constructor == Array. Given that limitation, no check is |
| 2524 // done here. In place, there are mjsunit tests harmony/array-species* which |
| 2525 // ensure that behavior is correct in various invalid protector cases. |
| 2526 |
| 2527 PropertyCell* species_cell = heap()->species_protector(); |
| 2528 return species_cell->value()->IsSmi() && |
| 2529 Smi::cast(species_cell->value())->value() == kArrayProtectorValid; |
| 2530 } |
| 2531 |
| 2532 void Isolate::InvalidateArraySpeciesProtector() { |
| 2533 DCHECK(factory()->species_protector()->value()->IsSmi()); |
| 2534 DCHECK(IsArraySpeciesLookupChainIntact()); |
| 2535 PropertyCell::SetValueWithInvalidation( |
| 2536 factory()->species_protector(), |
| 2537 handle(Smi::FromInt(kArrayProtectorInvalid), this)); |
| 2538 DCHECK(!IsArraySpeciesLookupChainIntact()); |
| 2539 } |
2514 | 2540 |
2515 void Isolate::UpdateArrayProtectorOnSetElement(Handle<JSObject> object) { | 2541 void Isolate::UpdateArrayProtectorOnSetElement(Handle<JSObject> object) { |
| 2542 DisallowHeapAllocation no_gc; |
2516 if (IsFastArrayConstructorPrototypeChainIntact() && | 2543 if (IsFastArrayConstructorPrototypeChainIntact() && |
2517 object->map()->is_prototype_map()) { | 2544 object->map()->is_prototype_map()) { |
2518 Object* context = heap()->native_contexts_list(); | 2545 Object* context = heap()->native_contexts_list(); |
2519 while (!context->IsUndefined()) { | 2546 while (!context->IsUndefined()) { |
2520 Context* current_context = Context::cast(context); | 2547 Context* current_context = Context::cast(context); |
2521 if (current_context->get(Context::INITIAL_OBJECT_PROTOTYPE_INDEX) == | 2548 if (current_context->get(Context::INITIAL_OBJECT_PROTOTYPE_INDEX) == |
2522 *object || | 2549 *object || |
2523 current_context->get(Context::INITIAL_ARRAY_PROTOTYPE_INDEX) == | 2550 current_context->get(Context::INITIAL_ARRAY_PROTOTYPE_INDEX) == |
2524 *object) { | 2551 *object) { |
| 2552 CountUsage(v8::Isolate::UseCounterFeature::kArrayProtectorDirtied); |
2525 PropertyCell::SetValueWithInvalidation( | 2553 PropertyCell::SetValueWithInvalidation( |
2526 factory()->array_protector(), | 2554 factory()->array_protector(), |
2527 handle(Smi::FromInt(kArrayProtectorInvalid), this)); | 2555 handle(Smi::FromInt(kArrayProtectorInvalid), this)); |
2528 break; | 2556 break; |
2529 } | 2557 } |
2530 context = current_context->get(Context::NEXT_CONTEXT_LINK); | 2558 context = current_context->get(Context::NEXT_CONTEXT_LINK); |
2531 } | 2559 } |
2532 } | 2560 } |
2533 } | 2561 } |
2534 | 2562 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2857 // Then check whether this scope intercepts. | 2885 // Then check whether this scope intercepts. |
2858 if ((flag & intercept_mask_)) { | 2886 if ((flag & intercept_mask_)) { |
2859 intercepted_flags_ |= flag; | 2887 intercepted_flags_ |= flag; |
2860 return true; | 2888 return true; |
2861 } | 2889 } |
2862 return false; | 2890 return false; |
2863 } | 2891 } |
2864 | 2892 |
2865 } // namespace internal | 2893 } // namespace internal |
2866 } // namespace v8 | 2894 } // namespace v8 |
OLD | NEW |