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

Side by Side Diff: src/heap.cc

Issue 8130002: Make accessors for oddball objects return Oddball* instead of Object*. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1786 matching lines...) Expand 10 before | Expand all | Expand 10 after
1797 1797
1798 // Allocate the empty array. 1798 // Allocate the empty array.
1799 { MaybeObject* maybe_obj = AllocateEmptyFixedArray(); 1799 { MaybeObject* maybe_obj = AllocateEmptyFixedArray();
1800 if (!maybe_obj->ToObject(&obj)) return false; 1800 if (!maybe_obj->ToObject(&obj)) return false;
1801 } 1801 }
1802 set_empty_fixed_array(FixedArray::cast(obj)); 1802 set_empty_fixed_array(FixedArray::cast(obj));
1803 1803
1804 { MaybeObject* maybe_obj = Allocate(oddball_map(), OLD_POINTER_SPACE); 1804 { MaybeObject* maybe_obj = Allocate(oddball_map(), OLD_POINTER_SPACE);
1805 if (!maybe_obj->ToObject(&obj)) return false; 1805 if (!maybe_obj->ToObject(&obj)) return false;
1806 } 1806 }
1807 set_null_value(obj); 1807 set_null_value(Oddball::cast(obj));
1808 Oddball::cast(obj)->set_kind(Oddball::kNull); 1808 Oddball::cast(obj)->set_kind(Oddball::kNull);
1809 1809
1810 { MaybeObject* maybe_obj = Allocate(oddball_map(), OLD_POINTER_SPACE);
1811 if (!maybe_obj->ToObject(&obj)) return false;
1812 }
1813 set_undefined_value(Oddball::cast(obj));
fschneider 2011/10/04 10:48:52 heap->undefined_value() is used by CreateApiObject
1814 Oddball::cast(obj)->set_kind(Oddball::kUndefined);
1815 ASSERT(!InNewSpace(undefined_value()));
1816
1810 // Allocate the empty descriptor array. 1817 // Allocate the empty descriptor array.
1811 { MaybeObject* maybe_obj = AllocateEmptyFixedArray(); 1818 { MaybeObject* maybe_obj = AllocateEmptyFixedArray();
1812 if (!maybe_obj->ToObject(&obj)) return false; 1819 if (!maybe_obj->ToObject(&obj)) return false;
1813 } 1820 }
1814 set_empty_descriptor_array(DescriptorArray::cast(obj)); 1821 set_empty_descriptor_array(DescriptorArray::cast(obj));
1815 1822
1816 // Fix the instance_descriptors for the existing maps. 1823 // Fix the instance_descriptors for the existing maps.
1817 meta_map()->init_instance_descriptors(); 1824 meta_map()->init_instance_descriptors();
1818 meta_map()->set_code_cache(empty_fixed_array()); 1825 meta_map()->set_code_cache(empty_fixed_array());
1819 meta_map()->set_prototype_transitions(empty_fixed_array()); 1826 meta_map()->set_prototype_transitions(empty_fixed_array());
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
2171 } 2178 }
2172 2179
2173 2180
2174 bool Heap::CreateInitialObjects() { 2181 bool Heap::CreateInitialObjects() {
2175 Object* obj; 2182 Object* obj;
2176 2183
2177 // The -0 value must be set before NumberFromDouble works. 2184 // The -0 value must be set before NumberFromDouble works.
2178 { MaybeObject* maybe_obj = AllocateHeapNumber(-0.0, TENURED); 2185 { MaybeObject* maybe_obj = AllocateHeapNumber(-0.0, TENURED);
2179 if (!maybe_obj->ToObject(&obj)) return false; 2186 if (!maybe_obj->ToObject(&obj)) return false;
2180 } 2187 }
2181 set_minus_zero_value(obj); 2188 set_minus_zero_value(HeapNumber::cast(obj));
2182 ASSERT(signbit(minus_zero_value()->Number()) != 0); 2189 ASSERT(signbit(minus_zero_value()->Number()) != 0);
2183 2190
2184 { MaybeObject* maybe_obj = AllocateHeapNumber(OS::nan_value(), TENURED); 2191 { MaybeObject* maybe_obj = AllocateHeapNumber(OS::nan_value(), TENURED);
2185 if (!maybe_obj->ToObject(&obj)) return false; 2192 if (!maybe_obj->ToObject(&obj)) return false;
2186 } 2193 }
2187 set_nan_value(obj); 2194 set_nan_value(HeapNumber::cast(obj));
2188 2195
2189 { MaybeObject* maybe_obj = AllocateHeapNumber(V8_INFINITY, TENURED); 2196 { MaybeObject* maybe_obj = AllocateHeapNumber(V8_INFINITY, TENURED);
2190 if (!maybe_obj->ToObject(&obj)) return false; 2197 if (!maybe_obj->ToObject(&obj)) return false;
2191 } 2198 }
2192 set_infinity_value(obj); 2199 set_infinity_value(HeapNumber::cast(obj));
2193
2194 { MaybeObject* maybe_obj = Allocate(oddball_map(), OLD_POINTER_SPACE);
2195 if (!maybe_obj->ToObject(&obj)) return false;
2196 }
2197 set_undefined_value(obj);
2198 Oddball::cast(obj)->set_kind(Oddball::kUndefined);
2199 ASSERT(!InNewSpace(undefined_value()));
2200 2200
2201 // Allocate initial symbol table. 2201 // Allocate initial symbol table.
2202 { MaybeObject* maybe_obj = SymbolTable::Allocate(kInitialSymbolTableSize); 2202 { MaybeObject* maybe_obj = SymbolTable::Allocate(kInitialSymbolTableSize);
2203 if (!maybe_obj->ToObject(&obj)) return false; 2203 if (!maybe_obj->ToObject(&obj)) return false;
2204 } 2204 }
2205 // Don't use set_symbol_table() due to asserts. 2205 // Don't use set_symbol_table() due to asserts.
2206 roots_[kSymbolTableRootIndex] = obj; 2206 roots_[kSymbolTableRootIndex] = obj;
2207 2207
2208 // Assign the print strings for oddballs after creating symboltable. 2208 // Finish initializing oddballs after creating symboltable.
2209 Object* symbol;
2210 { MaybeObject* maybe_symbol = LookupAsciiSymbol("undefined");
2211 if (!maybe_symbol->ToObject(&symbol)) return false;
2212 }
2213 Oddball::cast(undefined_value())->set_to_string(String::cast(symbol));
2214 Oddball::cast(undefined_value())->set_to_number(nan_value());
2215
2216 // Allocate the null_value
2217 { MaybeObject* maybe_obj = 2209 { MaybeObject* maybe_obj =
2218 Oddball::cast(null_value())->Initialize("null", 2210 undefined_value()->Initialize("undefined", nan_value(), Oddball::kUndefi ned);
Vyacheslav Egorov (Chromium) 2011/10/04 11:00:51 long line
fschneider 2011/10/04 11:28:16 Done.
2219 Smi::FromInt(0),
2220 Oddball::kNull);
2221 if (!maybe_obj->ToObject(&obj)) return false; 2211 if (!maybe_obj->ToObject(&obj)) return false;
2222 } 2212 }
2223 2213
2214 // Initialize the null_value.
2215 { MaybeObject* maybe_obj =
2216 null_value()->Initialize("null", Smi::FromInt(0), Oddball::kNull);
2217 if (!maybe_obj->ToObject(&obj)) return false;
2218 }
2219
2224 { MaybeObject* maybe_obj = CreateOddball("true", 2220 { MaybeObject* maybe_obj = CreateOddball("true",
2225 Smi::FromInt(1), 2221 Smi::FromInt(1),
2226 Oddball::kTrue); 2222 Oddball::kTrue);
2227 if (!maybe_obj->ToObject(&obj)) return false; 2223 if (!maybe_obj->ToObject(&obj)) return false;
2228 } 2224 }
2229 set_true_value(obj); 2225 set_true_value(Oddball::cast(obj));
2230 2226
2231 { MaybeObject* maybe_obj = CreateOddball("false", 2227 { MaybeObject* maybe_obj = CreateOddball("false",
2232 Smi::FromInt(0), 2228 Smi::FromInt(0),
2233 Oddball::kFalse); 2229 Oddball::kFalse);
2234 if (!maybe_obj->ToObject(&obj)) return false; 2230 if (!maybe_obj->ToObject(&obj)) return false;
2235 } 2231 }
2236 set_false_value(obj); 2232 set_false_value(Oddball::cast(obj));
2237 2233
2238 { MaybeObject* maybe_obj = CreateOddball("hole", 2234 { MaybeObject* maybe_obj = CreateOddball("hole",
2239 Smi::FromInt(-1), 2235 Smi::FromInt(-1),
2240 Oddball::kTheHole); 2236 Oddball::kTheHole);
2241 if (!maybe_obj->ToObject(&obj)) return false; 2237 if (!maybe_obj->ToObject(&obj)) return false;
2242 } 2238 }
2243 set_the_hole_value(obj); 2239 set_the_hole_value(Oddball::cast(obj));
2244 2240
2245 { MaybeObject* maybe_obj = CreateOddball("arguments_marker", 2241 { MaybeObject* maybe_obj = CreateOddball("arguments_marker",
2246 Smi::FromInt(-2), 2242 Smi::FromInt(-2),
2247 Oddball::kArgumentMarker); 2243 Oddball::kArgumentMarker);
2248 if (!maybe_obj->ToObject(&obj)) return false; 2244 if (!maybe_obj->ToObject(&obj)) return false;
2249 } 2245 }
2250 set_arguments_marker(obj); 2246 set_arguments_marker(Oddball::cast(obj));
2251 2247
2252 { MaybeObject* maybe_obj = CreateOddball("no_interceptor_result_sentinel", 2248 { MaybeObject* maybe_obj = CreateOddball("no_interceptor_result_sentinel",
2253 Smi::FromInt(-3), 2249 Smi::FromInt(-3),
2254 Oddball::kOther); 2250 Oddball::kOther);
2255 if (!maybe_obj->ToObject(&obj)) return false; 2251 if (!maybe_obj->ToObject(&obj)) return false;
2256 } 2252 }
2257 set_no_interceptor_result_sentinel(obj); 2253 set_no_interceptor_result_sentinel(obj);
2258 2254
2259 { MaybeObject* maybe_obj = CreateOddball("termination_exception", 2255 { MaybeObject* maybe_obj = CreateOddball("termination_exception",
2260 Smi::FromInt(-4), 2256 Smi::FromInt(-4),
2261 Oddball::kOther); 2257 Oddball::kOther);
2262 if (!maybe_obj->ToObject(&obj)) return false; 2258 if (!maybe_obj->ToObject(&obj)) return false;
2263 } 2259 }
2264 set_termination_exception(obj); 2260 set_termination_exception(obj);
2265 2261
2266 { MaybeObject* maybe_obj = CreateOddball("frame_alignment_marker", 2262 { MaybeObject* maybe_obj = CreateOddball("frame_alignment_marker",
2267 Smi::FromInt(-5), 2263 Smi::FromInt(-5),
2268 Oddball::kOther); 2264 Oddball::kOther);
2269 if (!maybe_obj->ToObject(&obj)) return false; 2265 if (!maybe_obj->ToObject(&obj)) return false;
2270 } 2266 }
2271 set_frame_alignment_marker(obj); 2267 set_frame_alignment_marker(Oddball::cast(obj));
2272 STATIC_ASSERT(Oddball::kLeastHiddenOddballNumber == -5); 2268 STATIC_ASSERT(Oddball::kLeastHiddenOddballNumber == -5);
2273 2269
2274 // Allocate the empty string. 2270 // Allocate the empty string.
2275 { MaybeObject* maybe_obj = AllocateRawAsciiString(0, TENURED); 2271 { MaybeObject* maybe_obj = AllocateRawAsciiString(0, TENURED);
2276 if (!maybe_obj->ToObject(&obj)) return false; 2272 if (!maybe_obj->ToObject(&obj)) return false;
2277 } 2273 }
2278 set_empty_string(String::cast(obj)); 2274 set_empty_string(String::cast(obj));
2279 2275
2280 for (unsigned i = 0; i < ARRAY_SIZE(constant_symbol_table); i++) { 2276 for (unsigned i = 0; i < ARRAY_SIZE(constant_symbol_table); i++) {
2281 { MaybeObject* maybe_obj = 2277 { MaybeObject* maybe_obj =
(...skipping 4188 matching lines...) Expand 10 before | Expand all | Expand 10 after
6470 isolate_->heap()->store_buffer()->Compact(); 6466 isolate_->heap()->store_buffer()->Compact();
6471 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); 6467 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED);
6472 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { 6468 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) {
6473 next = chunk->next_chunk(); 6469 next = chunk->next_chunk();
6474 isolate_->memory_allocator()->Free(chunk); 6470 isolate_->memory_allocator()->Free(chunk);
6475 } 6471 }
6476 chunks_queued_for_free_ = NULL; 6472 chunks_queued_for_free_ = NULL;
6477 } 6473 }
6478 6474
6479 } } // namespace v8::internal 6475 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698