OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 if (value->IsFixedArray()) { | 323 if (value->IsFixedArray()) { |
324 // The value contains the constant_properties of a | 324 // The value contains the constant_properties of a |
325 // simple object literal. | 325 // simple object literal. |
326 Handle<FixedArray> array = Handle<FixedArray>::cast(value); | 326 Handle<FixedArray> array = Handle<FixedArray>::cast(value); |
327 value = CreateLiteralBoilerplate(literals, array); | 327 value = CreateLiteralBoilerplate(literals, array); |
328 if (value.is_null()) return value; | 328 if (value.is_null()) return value; |
329 } | 329 } |
330 Handle<Object> result; | 330 Handle<Object> result; |
331 uint32_t element_index = 0; | 331 uint32_t element_index = 0; |
332 if (key->IsSymbol()) { | 332 if (key->IsSymbol()) { |
333 // If key is a symbol it is not an array element. | 333 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { |
334 Handle<String> name(String::cast(*key)); | 334 // Array index as string (uint32). |
335 ASSERT(!name->AsArrayIndex(&element_index)); | 335 result = SetOwnElement(boilerplate, element_index, value); |
336 result = SetProperty(boilerplate, name, value, NONE); | 336 } else { |
| 337 Handle<String> name(String::cast(*key)); |
| 338 ASSERT(!name->AsArrayIndex(&element_index)); |
| 339 result = IgnoreAttributesAndSetLocalProperty(boilerplate, name, |
| 340 value, NONE); |
| 341 } |
337 } else if (key->ToArrayIndex(&element_index)) { | 342 } else if (key->ToArrayIndex(&element_index)) { |
338 // Array index (uint32). | 343 // Array index (uint32). |
339 result = SetElement(boilerplate, element_index, value); | 344 result = SetOwnElement(boilerplate, element_index, value); |
340 } else { | 345 } else { |
341 // Non-uint32 number. | 346 // Non-uint32 number. |
342 ASSERT(key->IsNumber()); | 347 ASSERT(key->IsNumber()); |
343 double num = key->Number(); | 348 double num = key->Number(); |
344 char arr[100]; | 349 char arr[100]; |
345 Vector<char> buffer(arr, ARRAY_SIZE(arr)); | 350 Vector<char> buffer(arr, ARRAY_SIZE(arr)); |
346 const char* str = DoubleToCString(num, buffer); | 351 const char* str = DoubleToCString(num, buffer); |
347 Handle<String> name = Factory::NewStringFromAscii(CStrVector(str)); | 352 Handle<String> name = Factory::NewStringFromAscii(CStrVector(str)); |
348 result = SetProperty(boilerplate, name, value, NONE); | 353 result = IgnoreAttributesAndSetLocalProperty(boilerplate, name, |
| 354 value, NONE); |
349 } | 355 } |
350 // If setting the property on the boilerplate throws an | 356 // If setting the property on the boilerplate throws an |
351 // exception, the exception is converted to an empty handle in | 357 // exception, the exception is converted to an empty handle in |
352 // the handle based operations. In that case, we need to | 358 // the handle based operations. In that case, we need to |
353 // convert back to an exception. | 359 // convert back to an exception. |
354 if (result.is_null()) return result; | 360 if (result.is_null()) return result; |
355 } | 361 } |
356 } | 362 } |
357 | 363 |
358 return boilerplate; | 364 return boilerplate; |
(...skipping 10437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10796 } else { | 10802 } else { |
10797 // Handle last resort GC and make sure to allow future allocations | 10803 // Handle last resort GC and make sure to allow future allocations |
10798 // to grow the heap without causing GCs (if possible). | 10804 // to grow the heap without causing GCs (if possible). |
10799 Counters::gc_last_resort_from_js.Increment(); | 10805 Counters::gc_last_resort_from_js.Increment(); |
10800 Heap::CollectAllGarbage(false); | 10806 Heap::CollectAllGarbage(false); |
10801 } | 10807 } |
10802 } | 10808 } |
10803 | 10809 |
10804 | 10810 |
10805 } } // namespace v8::internal | 10811 } } // namespace v8::internal |
OLD | NEW |