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