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

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: split InitializeThreadLocal into two parts 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
« no previous file with comments | « src/heap.h ('k') | src/hydrogen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
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",
2219 Smi::FromInt(0), 2211 nan_value(),
2220 Oddball::kNull); 2212 Oddball::kUndefined);
2221 if (!maybe_obj->ToObject(&obj)) return false; 2213 if (!maybe_obj->ToObject(&obj)) return false;
2222 } 2214 }
2223 2215
2216 // Initialize the null_value.
2217 { MaybeObject* maybe_obj =
2218 null_value()->Initialize("null", Smi::FromInt(0), Oddball::kNull);
2219 if (!maybe_obj->ToObject(&obj)) return false;
2220 }
2221
2224 { MaybeObject* maybe_obj = CreateOddball("true", 2222 { MaybeObject* maybe_obj = CreateOddball("true",
2225 Smi::FromInt(1), 2223 Smi::FromInt(1),
2226 Oddball::kTrue); 2224 Oddball::kTrue);
2227 if (!maybe_obj->ToObject(&obj)) return false; 2225 if (!maybe_obj->ToObject(&obj)) return false;
2228 } 2226 }
2229 set_true_value(obj); 2227 set_true_value(Oddball::cast(obj));
2230 2228
2231 { MaybeObject* maybe_obj = CreateOddball("false", 2229 { MaybeObject* maybe_obj = CreateOddball("false",
2232 Smi::FromInt(0), 2230 Smi::FromInt(0),
2233 Oddball::kFalse); 2231 Oddball::kFalse);
2234 if (!maybe_obj->ToObject(&obj)) return false; 2232 if (!maybe_obj->ToObject(&obj)) return false;
2235 } 2233 }
2236 set_false_value(obj); 2234 set_false_value(Oddball::cast(obj));
2237 2235
2238 { MaybeObject* maybe_obj = CreateOddball("hole", 2236 { MaybeObject* maybe_obj = CreateOddball("hole",
2239 Smi::FromInt(-1), 2237 Smi::FromInt(-1),
2240 Oddball::kTheHole); 2238 Oddball::kTheHole);
2241 if (!maybe_obj->ToObject(&obj)) return false; 2239 if (!maybe_obj->ToObject(&obj)) return false;
2242 } 2240 }
2243 set_the_hole_value(obj); 2241 set_the_hole_value(Oddball::cast(obj));
2244 2242
2245 { MaybeObject* maybe_obj = CreateOddball("arguments_marker", 2243 { MaybeObject* maybe_obj = CreateOddball("arguments_marker",
2246 Smi::FromInt(-2), 2244 Smi::FromInt(-2),
2247 Oddball::kArgumentMarker); 2245 Oddball::kArgumentMarker);
2248 if (!maybe_obj->ToObject(&obj)) return false; 2246 if (!maybe_obj->ToObject(&obj)) return false;
2249 } 2247 }
2250 set_arguments_marker(obj); 2248 set_arguments_marker(Oddball::cast(obj));
2251 2249
2252 { MaybeObject* maybe_obj = CreateOddball("no_interceptor_result_sentinel", 2250 { MaybeObject* maybe_obj = CreateOddball("no_interceptor_result_sentinel",
2253 Smi::FromInt(-3), 2251 Smi::FromInt(-3),
2254 Oddball::kOther); 2252 Oddball::kOther);
2255 if (!maybe_obj->ToObject(&obj)) return false; 2253 if (!maybe_obj->ToObject(&obj)) return false;
2256 } 2254 }
2257 set_no_interceptor_result_sentinel(obj); 2255 set_no_interceptor_result_sentinel(obj);
2258 2256
2259 { MaybeObject* maybe_obj = CreateOddball("termination_exception", 2257 { MaybeObject* maybe_obj = CreateOddball("termination_exception",
2260 Smi::FromInt(-4), 2258 Smi::FromInt(-4),
2261 Oddball::kOther); 2259 Oddball::kOther);
2262 if (!maybe_obj->ToObject(&obj)) return false; 2260 if (!maybe_obj->ToObject(&obj)) return false;
2263 } 2261 }
2264 set_termination_exception(obj); 2262 set_termination_exception(obj);
2265 2263
2266 { MaybeObject* maybe_obj = CreateOddball("frame_alignment_marker", 2264 { MaybeObject* maybe_obj = CreateOddball("frame_alignment_marker",
2267 Smi::FromInt(-5), 2265 Smi::FromInt(-5),
2268 Oddball::kOther); 2266 Oddball::kOther);
2269 if (!maybe_obj->ToObject(&obj)) return false; 2267 if (!maybe_obj->ToObject(&obj)) return false;
2270 } 2268 }
2271 set_frame_alignment_marker(obj); 2269 set_frame_alignment_marker(Oddball::cast(obj));
2272 STATIC_ASSERT(Oddball::kLeastHiddenOddballNumber == -5); 2270 STATIC_ASSERT(Oddball::kLeastHiddenOddballNumber == -5);
2273 2271
2274 // Allocate the empty string. 2272 // Allocate the empty string.
2275 { MaybeObject* maybe_obj = AllocateRawAsciiString(0, TENURED); 2273 { MaybeObject* maybe_obj = AllocateRawAsciiString(0, TENURED);
2276 if (!maybe_obj->ToObject(&obj)) return false; 2274 if (!maybe_obj->ToObject(&obj)) return false;
2277 } 2275 }
2278 set_empty_string(String::cast(obj)); 2276 set_empty_string(String::cast(obj));
2279 2277
2280 for (unsigned i = 0; i < ARRAY_SIZE(constant_symbol_table); i++) { 2278 for (unsigned i = 0; i < ARRAY_SIZE(constant_symbol_table); i++) {
2281 { MaybeObject* maybe_obj = 2279 { MaybeObject* maybe_obj =
(...skipping 4188 matching lines...) Expand 10 before | Expand all | Expand 10 after
6470 isolate_->heap()->store_buffer()->Compact(); 6468 isolate_->heap()->store_buffer()->Compact();
6471 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); 6469 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED);
6472 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { 6470 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) {
6473 next = chunk->next_chunk(); 6471 next = chunk->next_chunk();
6474 isolate_->memory_allocator()->Free(chunk); 6472 isolate_->memory_allocator()->Free(chunk);
6475 } 6473 }
6476 chunks_queued_for_free_ = NULL; 6474 chunks_queued_for_free_ = NULL;
6477 } 6475 }
6478 6476
6479 } } // namespace v8::internal 6477 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698