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

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

Issue 1142493002: Use a private own symbol instead of a hidden property for hash codes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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
« src/objects.cc ('K') | « src/runtime/runtime-symbol.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 3262 matching lines...) Expand 10 before | Expand all | Expand 10 after
3273 *v8::Handle<v8::Function>::Cast( 3273 *v8::Handle<v8::Function>::Cast(
3274 CcTest::global()->Get(v8_str("g")))); 3274 CcTest::global()->Get(v8_str("g"))));
3275 3275
3276 OFStream os(stdout); 3276 OFStream os(stdout);
3277 g->shared()->Print(os); 3277 g->shared()->Print(os);
3278 os << std::endl; 3278 os << std::endl;
3279 } 3279 }
3280 #endif // OBJECT_PRINT 3280 #endif // OBJECT_PRINT
3281 3281
3282 3282
3283 TEST(Regress2211) {
3284 CcTest::InitializeVM();
3285 v8::HandleScope scope(CcTest::isolate());
3286
3287 v8::Handle<v8::String> value = v8_str("val string");
3288 Smi* hash = Smi::FromInt(321);
3289 Factory* factory = CcTest::i_isolate()->factory();
3290
3291 for (int i = 0; i < 2; i++) {
3292 // Store identity hash first and common hidden property second.
3293 v8::Handle<v8::Object> obj = v8::Object::New(CcTest::isolate());
3294 Handle<JSObject> internal_obj = v8::Utils::OpenHandle(*obj);
3295 CHECK(internal_obj->HasFastProperties());
3296
3297 // In the first iteration, set hidden value first and identity hash second.
3298 // In the second iteration, reverse the order.
3299 if (i == 0) obj->SetHiddenValue(v8_str("key string"), value);
3300 JSObject::SetIdentityHash(internal_obj, handle(hash, CcTest::i_isolate()));
3301 if (i == 1) obj->SetHiddenValue(v8_str("key string"), value);
3302
3303 // Check values.
3304 CHECK_EQ(hash,
3305 internal_obj->GetHiddenProperty(factory->identity_hash_string()));
3306 CHECK(value->Equals(obj->GetHiddenValue(v8_str("key string"))));
3307
3308 // Check size.
3309 FieldIndex index = FieldIndex::ForDescriptor(internal_obj->map(), 0);
3310 ObjectHashTable* hashtable = ObjectHashTable::cast(
3311 internal_obj->RawFastPropertyAt(index));
3312 // HashTable header (5) and 4 initial entries (8).
3313 CHECK_LE(hashtable->SizeFor(hashtable->length()), 13 * kPointerSize);
3314 }
3315 }
3316
3317
3318 TEST(IncrementalMarkingPreservesMonomorphicCallIC) { 3283 TEST(IncrementalMarkingPreservesMonomorphicCallIC) {
3319 if (i::FLAG_always_opt) return; 3284 if (i::FLAG_always_opt) return;
3320 CcTest::InitializeVM(); 3285 CcTest::InitializeVM();
3321 v8::HandleScope scope(CcTest::isolate()); 3286 v8::HandleScope scope(CcTest::isolate());
3322 v8::Local<v8::Value> fun1, fun2; 3287 v8::Local<v8::Value> fun1, fun2;
3323 3288
3324 { 3289 {
3325 LocalContext env; 3290 LocalContext env;
3326 CompileRun("function fun() {};"); 3291 CompileRun("function fun() {};");
3327 fun1 = env->Global()->Get(v8_str("fun")); 3292 fun1 = env->Global()->Get(v8_str("fun"));
(...skipping 2148 matching lines...) Expand 10 before | Expand all | Expand 10 after
5476 shared.SetWeak(&shared, SharedHasBeenCollected, 5441 shared.SetWeak(&shared, SharedHasBeenCollected,
5477 v8::WeakCallbackType::kParameter); 5442 v8::WeakCallbackType::kParameter);
5478 builtin_exports.SetWeak(&builtin_exports, BuiltinExportsHasBeenCollected, 5443 builtin_exports.SetWeak(&builtin_exports, BuiltinExportsHasBeenCollected,
5479 v8::WeakCallbackType::kParameter); 5444 v8::WeakCallbackType::kParameter);
5480 5445
5481 CcTest::heap()->CollectAllAvailableGarbage("fire weak callbacks"); 5446 CcTest::heap()->CollectAllAvailableGarbage("fire weak callbacks");
5482 5447
5483 CHECK(shared_has_been_collected); 5448 CHECK(shared_has_been_collected);
5484 CHECK(builtin_exports_has_been_collected); 5449 CHECK(builtin_exports_has_been_collected);
5485 } 5450 }
OLDNEW
« src/objects.cc ('K') | « src/runtime/runtime-symbol.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698