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 CHECK(factory()->species_protector()->value()->IsSmi()); | |
adamk
2016/02/19 00:01:17
Normally this and the surrounding CHECKs would be
Dan Ehrenberg
2016/02/19 00:15:37
That would be my intuition, except I was copying w
adamk
2016/02/19 01:06:01
I'll leave this to cbruni or other runtime folks s
Dan Ehrenberg
2016/02/19 02:16:41
Actually, I can't find those CHECKS I thought I wa
| |
2534 CHECK(IsArraySpeciesLookupChainIntact()); | |
2535 PropertyCell::SetValueWithInvalidation( | |
2536 factory()->species_protector(), | |
2537 handle(Smi::FromInt(kArrayProtectorInvalid), this)); | |
2538 CHECK(!IsArraySpeciesLookupChainIntact()); | |
2539 } | |
2514 | 2540 |
2515 void Isolate::UpdateArrayProtectorOnSetElement(Handle<JSObject> object) { | 2541 void Isolate::UpdateArrayProtectorOnSetElement(Handle<JSObject> object) { |
2516 if (IsFastArrayConstructorPrototypeChainIntact() && | 2542 if (IsFastArrayConstructorPrototypeChainIntact() && |
2517 object->map()->is_prototype_map()) { | 2543 object->map()->is_prototype_map()) { |
2518 Object* context = heap()->native_contexts_list(); | 2544 Object* context = heap()->native_contexts_list(); |
2519 while (!context->IsUndefined()) { | 2545 while (!context->IsUndefined()) { |
2520 Context* current_context = Context::cast(context); | 2546 Context* current_context = Context::cast(context); |
2521 if (current_context->get(Context::INITIAL_OBJECT_PROTOTYPE_INDEX) == | 2547 if (current_context->get(Context::INITIAL_OBJECT_PROTOTYPE_INDEX) == |
2522 *object || | 2548 *object || |
2523 current_context->get(Context::INITIAL_ARRAY_PROTOTYPE_INDEX) == | 2549 current_context->get(Context::INITIAL_ARRAY_PROTOTYPE_INDEX) == |
2524 *object) { | 2550 *object) { |
2551 CountUsage(v8::Isolate::UseCounterFeature::kArrayProtectorDirtied); | |
2525 PropertyCell::SetValueWithInvalidation( | 2552 PropertyCell::SetValueWithInvalidation( |
2526 factory()->array_protector(), | 2553 factory()->array_protector(), |
2527 handle(Smi::FromInt(kArrayProtectorInvalid), this)); | 2554 handle(Smi::FromInt(kArrayProtectorInvalid), this)); |
2528 break; | 2555 break; |
2529 } | 2556 } |
2530 context = current_context->get(Context::NEXT_CONTEXT_LINK); | 2557 context = current_context->get(Context::NEXT_CONTEXT_LINK); |
2531 } | 2558 } |
2532 } | 2559 } |
2533 } | 2560 } |
2534 | 2561 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2857 // Then check whether this scope intercepts. | 2884 // Then check whether this scope intercepts. |
2858 if ((flag & intercept_mask_)) { | 2885 if ((flag & intercept_mask_)) { |
2859 intercepted_flags_ |= flag; | 2886 intercepted_flags_ |= flag; |
2860 return true; | 2887 return true; |
2861 } | 2888 } |
2862 return false; | 2889 return false; |
2863 } | 2890 } |
2864 | 2891 |
2865 } // namespace internal | 2892 } // namespace internal |
2866 } // namespace v8 | 2893 } // namespace v8 |
OLD | NEW |