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

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

Issue 712943002: MapCache simplification. It is now a FixedArray that maps number of properties to a WeakCell with... (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime/runtime-literals.cc ('k') | no next file » | 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 21193 matching lines...) Expand 10 before | Expand all | Expand 10 after
21204 obj->Set(v8_num(2), v8_str("foobar")); 21204 obj->Set(v8_num(2), v8_str("foobar"));
21205 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_num(2))); 21205 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_num(2)));
21206 21206
21207 // Test non-smi case. 21207 // Test non-smi case.
21208 obj->ForceSet(v8_str("2000000000"), v8_str("DONT_CHANGE"), v8::ReadOnly); 21208 obj->ForceSet(v8_str("2000000000"), v8_str("DONT_CHANGE"), v8::ReadOnly);
21209 obj->Set(v8_str("2000000000"), v8_str("foobar")); 21209 obj->Set(v8_str("2000000000"), v8_str("foobar"));
21210 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("2000000000"))); 21210 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("2000000000")));
21211 } 21211 }
21212 21212
21213 21213
21214 static int CountLiveMapsInMapCache(i::Context* context) {
21215 i::FixedArray* map_cache = i::FixedArray::cast(context->map_cache());
21216 int length = map_cache->length();
21217 int count = 0;
21218 for (int i = 0; i < length; i++) {
21219 i::Object* value = map_cache->get(i);
21220 if (value->IsWeakCell() && !i::WeakCell::cast(value)->cleared()) count++;
21221 }
21222 return count;
21223 }
21224
21225
21214 THREADED_TEST(Regress1516) { 21226 THREADED_TEST(Regress1516) {
21215 LocalContext context; 21227 LocalContext context;
21216 v8::HandleScope scope(context->GetIsolate()); 21228 v8::HandleScope scope(context->GetIsolate());
21217 21229
21230 // Object with 20 properties is not a common case, so it should be removed
21231 // from the cache after GC.
21218 { v8::HandleScope temp_scope(context->GetIsolate()); 21232 { v8::HandleScope temp_scope(context->GetIsolate());
21219 CompileRun("({'a': 0})"); 21233 CompileRun(
21234 "({"
21235 "'a00': 0, 'a01': 0, 'a02': 0, 'a03': 0, 'a04': 0, "
21236 "'a05': 0, 'a06': 0, 'a07': 0, 'a08': 0, 'a09': 0, "
21237 "'a10': 0, 'a11': 0, 'a12': 0, 'a13': 0, 'a14': 0, "
21238 "'a15': 0, 'a16': 0, 'a17': 0, 'a18': 0, 'a19': 0, "
21239 "})");
21220 } 21240 }
21221 21241
21222 int elements; 21242 int elements = CountLiveMapsInMapCache(CcTest::i_isolate()->context());
21223 { i::MapCache* map_cache = 21243 CHECK_LE(1, elements);
21224 i::MapCache::cast(CcTest::i_isolate()->context()->map_cache());
21225 elements = map_cache->NumberOfElements();
21226 CHECK_LE(1, elements);
21227 }
21228 21244
21229 CcTest::heap()->CollectAllGarbage( 21245 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
21230 i::Heap::kAbortIncrementalMarkingMask); 21246
21231 { i::Object* raw_map_cache = CcTest::i_isolate()->context()->map_cache(); 21247 CHECK_GT(elements, CountLiveMapsInMapCache(CcTest::i_isolate()->context()));
21232 if (raw_map_cache != CcTest::heap()->undefined_value()) {
21233 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache);
21234 CHECK_GT(elements, map_cache->NumberOfElements());
21235 }
21236 }
21237 } 21248 }
21238 21249
21239 21250
21240 static bool BlockProtoNamedSecurityTestCallback(Local<v8::Object> global, 21251 static bool BlockProtoNamedSecurityTestCallback(Local<v8::Object> global,
21241 Local<Value> name, 21252 Local<Value> name,
21242 v8::AccessType type, 21253 v8::AccessType type,
21243 Local<Value> data) { 21254 Local<Value> data) {
21244 // Only block read access to __proto__. 21255 // Only block read access to __proto__.
21245 if (type == v8::ACCESS_GET && 21256 if (type == v8::ACCESS_GET &&
21246 name->IsString() && 21257 name->IsString() &&
(...skipping 2937 matching lines...) Expand 10 before | Expand all | Expand 10 after
24184 char chunk2[] = 24195 char chunk2[] =
24185 "XX\xec\x92\x81r = 13;\n" 24196 "XX\xec\x92\x81r = 13;\n"
24186 " return foob\xec\x92\x81\xec\x92\x81r;\n" 24197 " return foob\xec\x92\x81\xec\x92\x81r;\n"
24187 "}\n"; 24198 "}\n";
24188 chunk1[strlen(chunk1) - 1] = reference[0]; 24199 chunk1[strlen(chunk1) - 1] = reference[0];
24189 chunk2[0] = reference[1]; 24200 chunk2[0] = reference[1];
24190 chunk2[1] = reference[2]; 24201 chunk2[1] = reference[2];
24191 const char* chunks[] = {chunk1, chunk2, "foo();", NULL}; 24202 const char* chunks[] = {chunk1, chunk2, "foo();", NULL};
24192 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8); 24203 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8);
24193 } 24204 }
OLDNEW
« no previous file with comments | « src/runtime/runtime-literals.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698