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 <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 2357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2368 | 2368 |
2369 | 2369 |
2370 bool Isolate::use_crankshaft() const { | 2370 bool Isolate::use_crankshaft() const { |
2371 return FLAG_crankshaft && | 2371 return FLAG_crankshaft && |
2372 !serializer_enabled_ && | 2372 !serializer_enabled_ && |
2373 CpuFeatures::SupportsCrankshaft(); | 2373 CpuFeatures::SupportsCrankshaft(); |
2374 } | 2374 } |
2375 | 2375 |
2376 | 2376 |
2377 bool Isolate::IsFastArrayConstructorPrototypeChainIntact() { | 2377 bool Isolate::IsFastArrayConstructorPrototypeChainIntact() { |
2378 Handle<PropertyCell> no_elements_cell = | |
2379 handle(heap()->array_protector(), this); | |
2380 bool cell_reports_intact = no_elements_cell->value()->IsSmi() && | |
2381 Smi::cast(no_elements_cell->value())->value() == 1; | |
2382 | |
2383 #ifdef DEBUG | |
2378 Map* root_array_map = | 2384 Map* root_array_map = |
2379 get_initial_js_array_map(GetInitialFastElementsKind()); | 2385 get_initial_js_array_map(GetInitialFastElementsKind()); |
2380 DCHECK(root_array_map != NULL); | |
2381 JSObject* initial_array_proto = JSObject::cast(*initial_array_prototype()); | 2386 JSObject* initial_array_proto = JSObject::cast(*initial_array_prototype()); |
2387 JSObject* initial_object_proto = JSObject::cast(*initial_object_prototype()); | |
2388 | |
2389 if (root_array_map == NULL || initial_array_proto == initial_object_proto) { | |
2390 // We are in the bootstrapping process, and the entire check sequence | |
2391 // shouldn't be performed. | |
2392 return cell_reports_intact; | |
2393 } | |
2382 | 2394 |
2383 // Check that the array prototype hasn't been altered WRT empty elements. | 2395 // Check that the array prototype hasn't been altered WRT empty elements. |
2384 if (root_array_map->prototype() != initial_array_proto) return false; | 2396 if (root_array_map->prototype() != initial_array_proto) { |
2397 DCHECK_EQ(false, cell_reports_intact); | |
2398 return cell_reports_intact; | |
2399 } | |
2400 | |
2385 if (initial_array_proto->elements() != heap()->empty_fixed_array()) { | 2401 if (initial_array_proto->elements() != heap()->empty_fixed_array()) { |
2386 return false; | 2402 DCHECK_EQ(false, cell_reports_intact); |
2403 return cell_reports_intact; | |
2387 } | 2404 } |
2388 | 2405 |
2389 // Check that the object prototype hasn't been altered WRT empty elements. | 2406 // Check that the object prototype hasn't been altered WRT empty elements. |
2390 JSObject* initial_object_proto = JSObject::cast(*initial_object_prototype()); | |
2391 PrototypeIterator iter(this, initial_array_proto); | 2407 PrototypeIterator iter(this, initial_array_proto); |
2392 if (iter.IsAtEnd() || iter.GetCurrent() != initial_object_proto) { | 2408 if (iter.IsAtEnd() || iter.GetCurrent() != initial_object_proto) { |
2393 return false; | 2409 DCHECK_EQ(false, cell_reports_intact); |
2410 return cell_reports_intact; | |
2394 } | 2411 } |
2395 if (initial_object_proto->elements() != heap()->empty_fixed_array()) { | 2412 if (initial_object_proto->elements() != heap()->empty_fixed_array()) { |
2396 return false; | 2413 DCHECK_EQ(false, cell_reports_intact); |
2414 return cell_reports_intact; | |
2397 } | 2415 } |
2398 | 2416 |
2399 iter.Advance(); | 2417 iter.Advance(); |
2400 return iter.IsAtEnd(); | 2418 if (!iter.IsAtEnd()) { |
2419 DCHECK_EQ(false, cell_reports_intact); | |
2420 return cell_reports_intact; | |
2421 } | |
2422 | |
2423 #endif | |
2424 | |
2425 return cell_reports_intact; | |
2401 } | 2426 } |
2402 | 2427 |
2403 | 2428 |
2429 void Isolate::UpdateArrayProtectorOnSetElement(Handle<JSObject> object) { | |
2430 Handle<PropertyCell> array_protector = factory()->array_protector(); | |
2431 if (IsFastArrayConstructorPrototypeChainIntact() && | |
2432 object->map()->is_prototype_map()) { | |
2433 Object* context = heap()->native_contexts_list(); | |
2434 while (!context->IsUndefined()) { | |
2435 Context* current_context = Context::cast(context); | |
2436 if (current_context->get(Context::INITIAL_OBJECT_PROTOTYPE_INDEX) == | |
2437 *object || | |
2438 current_context->get(Context::INITIAL_ARRAY_PROTOTYPE_INDEX) == | |
2439 *object) { | |
2440 PrintF("INVALIDATING YOU!!!\n"); | |
Jakob Kummerow
2015/04/22 08:02:20
yeah...
mvstanton
2015/04/22 09:39:07
I've discovered a bit of drama livens up the workd
| |
2441 PropertyCell::SetValueWithInvalidation(array_protector, | |
2442 handle(Smi::FromInt(0), this)); | |
2443 break; | |
2444 } | |
2445 context = current_context->get(Context::NEXT_CONTEXT_LINK); | |
2446 } | |
2447 } | |
2448 } | |
2449 | |
2450 | |
2451 bool Isolate::IsAnyInitialArrayPrototype(Handle<JSArray> array) { | |
2452 if (array->map()->is_prototype_map()) { | |
2453 Object* context = heap()->native_contexts_list(); | |
2454 while (!context->IsUndefined()) { | |
2455 Context* current_context = Context::cast(context); | |
2456 if (current_context->get(Context::INITIAL_ARRAY_PROTOTYPE_INDEX) == | |
2457 *array) { | |
2458 return true; | |
2459 } | |
2460 context = current_context->get(Context::NEXT_CONTEXT_LINK); | |
2461 } | |
2462 } | |
2463 return false; | |
2464 } | |
2465 | |
2466 | |
2404 CallInterfaceDescriptorData* Isolate::call_descriptor_data(int index) { | 2467 CallInterfaceDescriptorData* Isolate::call_descriptor_data(int index) { |
2405 DCHECK(0 <= index && index < CallDescriptors::NUMBER_OF_DESCRIPTORS); | 2468 DCHECK(0 <= index && index < CallDescriptors::NUMBER_OF_DESCRIPTORS); |
2406 return &call_descriptor_data_[index]; | 2469 return &call_descriptor_data_[index]; |
2407 } | 2470 } |
2408 | 2471 |
2409 | 2472 |
2410 Object* Isolate::FindCodeObject(Address a) { | 2473 Object* Isolate::FindCodeObject(Address a) { |
2411 return inner_pointer_to_code_cache()->GcSafeFindCodeForInnerPointer(a); | 2474 return inner_pointer_to_code_cache()->GcSafeFindCodeForInnerPointer(a); |
2412 } | 2475 } |
2413 | 2476 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2666 if (prev_ && prev_->Intercept(flag)) return true; | 2729 if (prev_ && prev_->Intercept(flag)) return true; |
2667 // Then check whether this scope intercepts. | 2730 // Then check whether this scope intercepts. |
2668 if ((flag & intercept_mask_)) { | 2731 if ((flag & intercept_mask_)) { |
2669 intercepted_flags_ |= flag; | 2732 intercepted_flags_ |= flag; |
2670 return true; | 2733 return true; |
2671 } | 2734 } |
2672 return false; | 2735 return false; |
2673 } | 2736 } |
2674 | 2737 |
2675 } } // namespace v8::internal | 2738 } } // namespace v8::internal |
OLD | NEW |