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

Side by Side Diff: test/cctest/test-api.cc

Issue 1092043002: Protect the emptiness of Array prototype elements with a PropertyCell. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Try again :p. 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/objects.cc ('k') | test/mjsunit/concurrent-initial-prototype-change.js » ('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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 16623 matching lines...) Expand 10 before | Expand all | Expand 10 after
16634 last_location = last_message = NULL; 16634 last_location = last_message = NULL;
16635 // Still entered, should fail. 16635 // Still entered, should fail.
16636 isolate->Dispose(); 16636 isolate->Dispose();
16637 CHECK(last_location); 16637 CHECK(last_location);
16638 CHECK(last_message); 16638 CHECK(last_message);
16639 } 16639 }
16640 isolate->Dispose(); 16640 isolate->Dispose();
16641 } 16641 }
16642 16642
16643 16643
16644 static void BreakArrayGuarantees(const char* script) {
16645 v8::Isolate* isolate1 = v8::Isolate::New();
16646 isolate1->Enter();
16647 v8::Persistent<v8::Context> context1;
16648 {
16649 v8::HandleScope scope(isolate1);
16650 context1.Reset(isolate1, Context::New(isolate1));
16651 }
16652
16653 {
16654 v8::HandleScope scope(isolate1);
16655 v8::Local<v8::Context> context =
16656 v8::Local<v8::Context>::New(isolate1, context1);
16657 v8::Context::Scope context_scope(context);
16658 v8::internal::Isolate* i_isolate =
16659 reinterpret_cast<v8::internal::Isolate*>(isolate1);
16660 CHECK_EQ(true, i_isolate->IsFastArrayConstructorPrototypeChainIntact());
16661 // Run something in new isolate.
16662 CompileRun(script);
16663 CHECK_EQ(false, i_isolate->IsFastArrayConstructorPrototypeChainIntact());
16664 }
16665 isolate1->Exit();
16666 isolate1->Dispose();
16667 }
16668
16669
16670 TEST(VerifyArrayPrototypeGuarantees) {
16671 // Break fast array hole handling by element changes.
16672 BreakArrayGuarantees("[].__proto__[1] = 3;");
16673 BreakArrayGuarantees("Object.prototype[3] = 'three';");
16674 BreakArrayGuarantees("Array.prototype.push(1);");
16675 BreakArrayGuarantees("Array.prototype.unshift(1);");
16676 // Break fast array hole handling by prototype structure changes.
16677 BreakArrayGuarantees("[].__proto__.__proto__ = { funny: true };");
16678 // By sending elements to dictionary mode.
16679 BreakArrayGuarantees("Object.freeze(Array.prototype);");
16680 BreakArrayGuarantees("Object.freeze(Object.prototype);");
16681 BreakArrayGuarantees(
16682 "Object.defineProperty(Array.prototype, 0, {"
16683 " get: function() { return 3; }});");
16684 BreakArrayGuarantees(
16685 "Object.defineProperty(Object.prototype, 0, {"
16686 " get: function() { return 3; }});");
16687 }
16688
16689
16644 TEST(RunTwoIsolatesOnSingleThread) { 16690 TEST(RunTwoIsolatesOnSingleThread) {
16645 // Run isolate 1. 16691 // Run isolate 1.
16646 v8::Isolate* isolate1 = v8::Isolate::New(); 16692 v8::Isolate* isolate1 = v8::Isolate::New();
16647 isolate1->Enter(); 16693 isolate1->Enter();
16648 v8::Persistent<v8::Context> context1; 16694 v8::Persistent<v8::Context> context1;
16649 { 16695 {
16650 v8::HandleScope scope(isolate1); 16696 v8::HandleScope scope(isolate1);
16651 context1.Reset(isolate1, Context::New(isolate1)); 16697 context1.Reset(isolate1, Context::New(isolate1));
16652 } 16698 }
16653 16699
(...skipping 4364 matching lines...) Expand 10 before | Expand all | Expand 10 after
21018 21064
21019 { 21065 {
21020 v8::HandleScope handle_scope(isolate); 21066 v8::HandleScope handle_scope(isolate);
21021 21067
21022 // Should work 21068 // Should work
21023 v8::Local<v8::Object> obj = v8::Object::New(isolate); 21069 v8::Local<v8::Object> obj = v8::Object::New(isolate);
21024 21070
21025 USE(obj); 21071 USE(obj);
21026 } 21072 }
21027 } 21073 }
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/concurrent-initial-prototype-change.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698