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

Side by Side Diff: src/isolate.cc

Issue 1099453007: Empty Array prototype elements protection needs to alert on length change. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: With comments. Created 5 years, 8 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/isolate.h ('k') | src/objects.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 // 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 <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include <fstream> // NOLINT(readability/streams) 7 #include <fstream> // NOLINT(readability/streams)
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/v8.h" 10 #include "src/v8.h"
(...skipping 2356 matching lines...) Expand 10 before | Expand all | Expand 10 after
2367 2367
2368 2368
2369 bool Isolate::use_crankshaft() const { 2369 bool Isolate::use_crankshaft() const {
2370 return FLAG_crankshaft && 2370 return FLAG_crankshaft &&
2371 !serializer_enabled_ && 2371 !serializer_enabled_ &&
2372 CpuFeatures::SupportsCrankshaft(); 2372 CpuFeatures::SupportsCrankshaft();
2373 } 2373 }
2374 2374
2375 2375
2376 bool Isolate::IsFastArrayConstructorPrototypeChainIntact() { 2376 bool Isolate::IsFastArrayConstructorPrototypeChainIntact() {
2377 Handle<PropertyCell> no_elements_cell = 2377 PropertyCell* no_elements_cell = heap()->array_protector();
2378 handle(heap()->array_protector(), this);
2379 bool cell_reports_intact = no_elements_cell->value()->IsSmi() && 2378 bool cell_reports_intact = no_elements_cell->value()->IsSmi() &&
2380 Smi::cast(no_elements_cell->value())->value() == 1; 2379 Smi::cast(no_elements_cell->value())->value() == 1;
2381 2380
2382 #ifdef DEBUG 2381 #ifdef DEBUG
2383 Map* root_array_map = 2382 Map* root_array_map =
2384 get_initial_js_array_map(GetInitialFastElementsKind()); 2383 get_initial_js_array_map(GetInitialFastElementsKind());
2385 JSObject* initial_array_proto = JSObject::cast(*initial_array_prototype()); 2384 Context* native_context = context()->native_context();
2386 JSObject* initial_object_proto = JSObject::cast(*initial_object_prototype()); 2385 JSObject* initial_array_proto = JSObject::cast(
2386 native_context->get(Context::INITIAL_ARRAY_PROTOTYPE_INDEX));
2387 JSObject* initial_object_proto = JSObject::cast(
2388 native_context->get(Context::INITIAL_OBJECT_PROTOTYPE_INDEX));
2387 2389
2388 if (root_array_map == NULL || initial_array_proto == initial_object_proto) { 2390 if (root_array_map == NULL || initial_array_proto == initial_object_proto) {
2389 // We are in the bootstrapping process, and the entire check sequence 2391 // We are in the bootstrapping process, and the entire check sequence
2390 // shouldn't be performed. 2392 // shouldn't be performed.
2391 return cell_reports_intact; 2393 return cell_reports_intact;
2392 } 2394 }
2393 2395
2394 // Check that the array prototype hasn't been altered WRT empty elements. 2396 // Check that the array prototype hasn't been altered WRT empty elements.
2395 if (root_array_map->prototype() != initial_array_proto) { 2397 if (root_array_map->prototype() != initial_array_proto) {
2396 DCHECK_EQ(false, cell_reports_intact); 2398 DCHECK_EQ(false, cell_reports_intact);
(...skipping 22 matching lines...) Expand all
2419 return cell_reports_intact; 2421 return cell_reports_intact;
2420 } 2422 }
2421 2423
2422 #endif 2424 #endif
2423 2425
2424 return cell_reports_intact; 2426 return cell_reports_intact;
2425 } 2427 }
2426 2428
2427 2429
2428 void Isolate::UpdateArrayProtectorOnSetElement(Handle<JSObject> object) { 2430 void Isolate::UpdateArrayProtectorOnSetElement(Handle<JSObject> object) {
2429 Handle<PropertyCell> array_protector = factory()->array_protector();
2430 if (IsFastArrayConstructorPrototypeChainIntact() && 2431 if (IsFastArrayConstructorPrototypeChainIntact() &&
2431 object->map()->is_prototype_map()) { 2432 object->map()->is_prototype_map()) {
2432 Object* context = heap()->native_contexts_list(); 2433 Object* context = heap()->native_contexts_list();
2433 while (!context->IsUndefined()) { 2434 while (!context->IsUndefined()) {
2434 Context* current_context = Context::cast(context); 2435 Context* current_context = Context::cast(context);
2435 if (current_context->get(Context::INITIAL_OBJECT_PROTOTYPE_INDEX) == 2436 if (current_context->get(Context::INITIAL_OBJECT_PROTOTYPE_INDEX) ==
2436 *object || 2437 *object ||
2437 current_context->get(Context::INITIAL_ARRAY_PROTOTYPE_INDEX) == 2438 current_context->get(Context::INITIAL_ARRAY_PROTOTYPE_INDEX) ==
2438 *object) { 2439 *object) {
2439 PropertyCell::SetValueWithInvalidation(array_protector, 2440 PropertyCell::SetValueWithInvalidation(factory()->array_protector(),
2440 handle(Smi::FromInt(0), this)); 2441 handle(Smi::FromInt(0), this));
2441 break; 2442 break;
2442 } 2443 }
2443 context = current_context->get(Context::NEXT_CONTEXT_LINK); 2444 context = current_context->get(Context::NEXT_CONTEXT_LINK);
2444 } 2445 }
2445 } 2446 }
2446 } 2447 }
2447 2448
2448 2449
2449 bool Isolate::IsAnyInitialArrayPrototype(Handle<JSArray> array) { 2450 bool Isolate::IsAnyInitialArrayPrototype(Handle<JSArray> array) {
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
2751 if (prev_ && prev_->Intercept(flag)) return true; 2752 if (prev_ && prev_->Intercept(flag)) return true;
2752 // Then check whether this scope intercepts. 2753 // Then check whether this scope intercepts.
2753 if ((flag & intercept_mask_)) { 2754 if ((flag & intercept_mask_)) {
2754 intercepted_flags_ |= flag; 2755 intercepted_flags_ |= flag;
2755 return true; 2756 return true;
2756 } 2757 }
2757 return false; 2758 return false;
2758 } 2759 }
2759 2760
2760 } } // namespace v8::internal 2761 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698