OLD | NEW |
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 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 CHECK(!heap->always_allocate()); | 1011 CHECK(!heap->always_allocate()); |
1012 Object* array = heap->AllocateFixedArray(fixed_array_len).ToObjectChecked(); | 1012 Object* array = heap->AllocateFixedArray(fixed_array_len).ToObjectChecked(); |
1013 CHECK(new_space->Contains(array)); | 1013 CHECK(new_space->Contains(array)); |
1014 | 1014 |
1015 Object* object = heap->AllocateJSObjectFromMap(*my_map).ToObjectChecked(); | 1015 Object* object = heap->AllocateJSObjectFromMap(*my_map).ToObjectChecked(); |
1016 CHECK(new_space->Contains(object)); | 1016 CHECK(new_space->Contains(object)); |
1017 JSObject* jsobject = JSObject::cast(object); | 1017 JSObject* jsobject = JSObject::cast(object); |
1018 CHECK_EQ(0, FixedArray::cast(jsobject->elements())->length()); | 1018 CHECK_EQ(0, FixedArray::cast(jsobject->elements())->length()); |
1019 CHECK_EQ(0, jsobject->properties()->length()); | 1019 CHECK_EQ(0, jsobject->properties()->length()); |
1020 // Create a reference to object in new space in jsobject. | 1020 // Create a reference to object in new space in jsobject. |
1021 jsobject->FastPropertyAtPut(-1, array); | 1021 FieldIndex index = FieldIndex::ForInObjectOffset( |
| 1022 JSObject::kHeaderSize - kPointerSize); |
| 1023 jsobject->FastPropertyAtPut(index, array); |
1022 | 1024 |
1023 CHECK_EQ(0, static_cast<int>(*limit_addr - *top_addr)); | 1025 CHECK_EQ(0, static_cast<int>(*limit_addr - *top_addr)); |
1024 | 1026 |
1025 // Step 4: clone jsobject, but force always allocate first to create a clone | 1027 // Step 4: clone jsobject, but force always allocate first to create a clone |
1026 // in old pointer space. | 1028 // in old pointer space. |
1027 Address old_pointer_space_top = heap->old_pointer_space()->top(); | 1029 Address old_pointer_space_top = heap->old_pointer_space()->top(); |
1028 AlwaysAllocateScope aa_scope(isolate); | 1030 AlwaysAllocateScope aa_scope(isolate); |
1029 Object* clone_obj = heap->CopyJSObject(jsobject).ToObjectChecked(); | 1031 Object* clone_obj = heap->CopyJSObject(jsobject).ToObjectChecked(); |
1030 JSObject* clone = JSObject::cast(clone_obj); | 1032 JSObject* clone = JSObject::cast(clone_obj); |
1031 if (clone->address() != old_pointer_space_top) { | 1033 if (clone->address() != old_pointer_space_top) { |
(...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2311 "%%OptimizeFunctionOnNextCall(f);" | 2313 "%%OptimizeFunctionOnNextCall(f);" |
2312 "f();", | 2314 "f();", |
2313 AllocationSite::kPretenureMinimumCreated); | 2315 AllocationSite::kPretenureMinimumCreated); |
2314 | 2316 |
2315 v8::Local<v8::Value> res = CompileRun(source.start()); | 2317 v8::Local<v8::Value> res = CompileRun(source.start()); |
2316 | 2318 |
2317 Handle<JSObject> o = | 2319 Handle<JSObject> o = |
2318 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2320 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2319 | 2321 |
2320 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2322 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
2321 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(0))); | 2323 FieldIndex idx1 = FieldIndex::ForPropertyIndex(o->map(), 0); |
2322 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(1))); | 2324 FieldIndex idx2 = FieldIndex::ForPropertyIndex(o->map(), 1); |
| 2325 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(idx1))); |
| 2326 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(idx2))); |
2323 | 2327 |
2324 JSObject* inner_object = reinterpret_cast<JSObject*>(o->RawFastPropertyAt(0)); | 2328 JSObject* inner_object = |
| 2329 reinterpret_cast<JSObject*>(o->RawFastPropertyAt(idx1)); |
2325 CHECK(CcTest::heap()->InOldPointerSpace(inner_object)); | 2330 CHECK(CcTest::heap()->InOldPointerSpace(inner_object)); |
2326 CHECK(CcTest::heap()->InOldDataSpace(inner_object->RawFastPropertyAt(0))); | 2331 CHECK(CcTest::heap()->InOldDataSpace(inner_object->RawFastPropertyAt(idx1))); |
2327 CHECK(CcTest::heap()->InOldPointerSpace(inner_object->RawFastPropertyAt(1))); | 2332 CHECK(CcTest::heap()->InOldPointerSpace( |
| 2333 inner_object->RawFastPropertyAt(idx2))); |
2328 } | 2334 } |
2329 | 2335 |
2330 | 2336 |
2331 TEST(OptimizedPretenuringDoubleArrayProperties) { | 2337 TEST(OptimizedPretenuringDoubleArrayProperties) { |
2332 i::FLAG_allow_natives_syntax = true; | 2338 i::FLAG_allow_natives_syntax = true; |
2333 i::FLAG_expose_gc = true; | 2339 i::FLAG_expose_gc = true; |
2334 CcTest::InitializeVM(); | 2340 CcTest::InitializeVM(); |
2335 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2341 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2336 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2342 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2337 v8::HandleScope scope(CcTest::isolate()); | 2343 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3074 if (i == 0) obj->SetHiddenValue(v8_str("key string"), value); | 3080 if (i == 0) obj->SetHiddenValue(v8_str("key string"), value); |
3075 JSObject::SetIdentityHash(internal_obj, handle(hash, CcTest::i_isolate())); | 3081 JSObject::SetIdentityHash(internal_obj, handle(hash, CcTest::i_isolate())); |
3076 if (i == 1) obj->SetHiddenValue(v8_str("key string"), value); | 3082 if (i == 1) obj->SetHiddenValue(v8_str("key string"), value); |
3077 | 3083 |
3078 // Check values. | 3084 // Check values. |
3079 CHECK_EQ(hash, | 3085 CHECK_EQ(hash, |
3080 internal_obj->GetHiddenProperty(factory->identity_hash_string())); | 3086 internal_obj->GetHiddenProperty(factory->identity_hash_string())); |
3081 CHECK(value->Equals(obj->GetHiddenValue(v8_str("key string")))); | 3087 CHECK(value->Equals(obj->GetHiddenValue(v8_str("key string")))); |
3082 | 3088 |
3083 // Check size. | 3089 // Check size. |
3084 DescriptorArray* descriptors = internal_obj->map()->instance_descriptors(); | 3090 FieldIndex index = FieldIndex::ForDescriptor(internal_obj->map(), 0); |
3085 ObjectHashTable* hashtable = ObjectHashTable::cast( | 3091 ObjectHashTable* hashtable = ObjectHashTable::cast( |
3086 internal_obj->RawFastPropertyAt(descriptors->GetFieldIndex(0))); | 3092 internal_obj->RawFastPropertyAt(index)); |
3087 // HashTable header (5) and 4 initial entries (8). | 3093 // HashTable header (5) and 4 initial entries (8). |
3088 CHECK_LE(hashtable->SizeFor(hashtable->length()), 13 * kPointerSize); | 3094 CHECK_LE(hashtable->SizeFor(hashtable->length()), 13 * kPointerSize); |
3089 } | 3095 } |
3090 } | 3096 } |
3091 | 3097 |
3092 | 3098 |
3093 TEST(IncrementalMarkingClearsTypeFeedbackInfo) { | 3099 TEST(IncrementalMarkingClearsTypeFeedbackInfo) { |
3094 if (i::FLAG_always_opt) return; | 3100 if (i::FLAG_always_opt) return; |
3095 CcTest::InitializeVM(); | 3101 CcTest::InitializeVM(); |
3096 v8::HandleScope scope(CcTest::isolate()); | 3102 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4326 #ifdef DEBUG | 4332 #ifdef DEBUG |
4327 TEST(PathTracer) { | 4333 TEST(PathTracer) { |
4328 CcTest::InitializeVM(); | 4334 CcTest::InitializeVM(); |
4329 v8::HandleScope scope(CcTest::isolate()); | 4335 v8::HandleScope scope(CcTest::isolate()); |
4330 | 4336 |
4331 v8::Local<v8::Value> result = CompileRun("'abc'"); | 4337 v8::Local<v8::Value> result = CompileRun("'abc'"); |
4332 Handle<Object> o = v8::Utils::OpenHandle(*result); | 4338 Handle<Object> o = v8::Utils::OpenHandle(*result); |
4333 CcTest::i_isolate()->heap()->TracePathToObject(*o); | 4339 CcTest::i_isolate()->heap()->TracePathToObject(*o); |
4334 } | 4340 } |
4335 #endif // DEBUG | 4341 #endif // DEBUG |
OLD | NEW |