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

Side by Side Diff: src/runtime.cc

Issue 14721009: Track computed literal properties. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 7 years, 6 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 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 // when extending the object multiple properties. Indicate the number of 248 // when extending the object multiple properties. Indicate the number of
249 // properties to be added. 249 // properties to be added.
250 JSObject::NormalizeProperties( 250 JSObject::NormalizeProperties(
251 boilerplate, KEEP_INOBJECT_PROPERTIES, length / 2); 251 boilerplate, KEEP_INOBJECT_PROPERTIES, length / 2);
252 } 252 }
253 253
254 // TODO(verwaest): Support tracking representations in the boilerplate. 254 // TODO(verwaest): Support tracking representations in the boilerplate.
255 for (int index = 0; index < length; index +=2) { 255 for (int index = 0; index < length; index +=2) {
256 Handle<Object> key(constant_properties->get(index+0), isolate); 256 Handle<Object> key(constant_properties->get(index+0), isolate);
257 Handle<Object> value(constant_properties->get(index+1), isolate); 257 Handle<Object> value(constant_properties->get(index+1), isolate);
258 Object::ValueType value_type = Object::REAL_VALUE;
258 if (value->IsFixedArray()) { 259 if (value->IsFixedArray()) {
259 // The value contains the constant_properties of a 260 // The value contains the constant_properties of a
260 // simple object or array literal. 261 // simple object or array literal.
261 Handle<FixedArray> array = Handle<FixedArray>::cast(value); 262 Handle<FixedArray> array = Handle<FixedArray>::cast(value);
262 value = CreateLiteralBoilerplate(isolate, literals, array); 263 value = CreateLiteralBoilerplate(isolate, literals, array);
263 if (value.is_null()) return value; 264 if (value.is_null()) return value;
265 } else if (FLAG_track_computed_fields && value->IsUndefined()) {
266 value_type = Object::PLACEHOLDER_VALUE;
264 } 267 }
265 Handle<Object> result; 268 Handle<Object> result;
266 uint32_t element_index = 0; 269 uint32_t element_index = 0;
267 if (key->IsInternalizedString()) { 270 if (key->IsInternalizedString()) {
268 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { 271 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) {
269 // Array index as string (uint32). 272 // Array index as string (uint32).
270 result = JSObject::SetOwnElement( 273 result = JSObject::SetOwnElement(
271 boilerplate, element_index, value, kNonStrictMode); 274 boilerplate, element_index, value, kNonStrictMode);
272 } else { 275 } else {
273 Handle<String> name(String::cast(*key)); 276 Handle<String> name(String::cast(*key));
274 ASSERT(!name->AsArrayIndex(&element_index)); 277 ASSERT(!name->AsArrayIndex(&element_index));
275 result = JSObject::SetLocalPropertyIgnoreAttributes( 278 result = JSObject::SetLocalPropertyIgnoreAttributes(
276 boilerplate, name, value, NONE); 279 boilerplate, name, value, NONE, value_type);
277 } 280 }
278 } else if (key->ToArrayIndex(&element_index)) { 281 } else if (key->ToArrayIndex(&element_index)) {
279 // Array index (uint32). 282 // Array index (uint32).
280 result = JSObject::SetOwnElement( 283 result = JSObject::SetOwnElement(
281 boilerplate, element_index, value, kNonStrictMode); 284 boilerplate, element_index, value, kNonStrictMode);
282 } else { 285 } else {
283 // Non-uint32 number. 286 // Non-uint32 number.
284 ASSERT(key->IsNumber()); 287 ASSERT(key->IsNumber());
285 double num = key->Number(); 288 double num = key->Number();
286 char arr[100]; 289 char arr[100];
287 Vector<char> buffer(arr, ARRAY_SIZE(arr)); 290 Vector<char> buffer(arr, ARRAY_SIZE(arr));
288 const char* str = DoubleToCString(num, buffer); 291 const char* str = DoubleToCString(num, buffer);
289 Handle<String> name = 292 Handle<String> name =
290 isolate->factory()->NewStringFromAscii(CStrVector(str)); 293 isolate->factory()->NewStringFromAscii(CStrVector(str));
291 result = JSObject::SetLocalPropertyIgnoreAttributes( 294 result = JSObject::SetLocalPropertyIgnoreAttributes(
292 boilerplate, name, value, NONE); 295 boilerplate, name, value, NONE, value_type);
293 } 296 }
294 // If setting the property on the boilerplate throws an 297 // If setting the property on the boilerplate throws an
295 // exception, the exception is converted to an empty handle in 298 // exception, the exception is converted to an empty handle in
296 // the handle based operations. In that case, we need to 299 // the handle based operations. In that case, we need to
297 // convert back to an exception. 300 // convert back to an exception.
298 if (result.is_null()) return result; 301 if (result.is_null()) return result;
299 } 302 }
300 303
301 // Transform to fast properties if necessary. For object literals with 304 // Transform to fast properties if necessary. For object literals with
302 // containing function literals we defer this operation until after all 305 // containing function literals we defer this operation until after all
(...skipping 13221 matching lines...) Expand 10 before | Expand all | Expand 10 after
13524 // Handle last resort GC and make sure to allow future allocations 13527 // Handle last resort GC and make sure to allow future allocations
13525 // to grow the heap without causing GCs (if possible). 13528 // to grow the heap without causing GCs (if possible).
13526 isolate->counters()->gc_last_resort_from_js()->Increment(); 13529 isolate->counters()->gc_last_resort_from_js()->Increment();
13527 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13530 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13528 "Runtime::PerformGC"); 13531 "Runtime::PerformGC");
13529 } 13532 }
13530 } 13533 }
13531 13534
13532 13535
13533 } } // namespace v8::internal 13536 } } // namespace v8::internal
OLDNEW
« src/parser.cc ('K') | « src/property-details.h ('k') | src/x64/lithium-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698