OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 Handle<Object> value(constant_properties->get(index+1)); | 298 Handle<Object> value(constant_properties->get(index+1)); |
299 if (value->IsFixedArray()) { | 299 if (value->IsFixedArray()) { |
300 // The value contains the constant_properties of a | 300 // The value contains the constant_properties of a |
301 // simple object literal. | 301 // simple object literal. |
302 Handle<FixedArray> array = Handle<FixedArray>::cast(value); | 302 Handle<FixedArray> array = Handle<FixedArray>::cast(value); |
303 value = CreateLiteralBoilerplate(literals, array); | 303 value = CreateLiteralBoilerplate(literals, array); |
304 if (value.is_null()) return value; | 304 if (value.is_null()) return value; |
305 } | 305 } |
306 Handle<Object> result; | 306 Handle<Object> result; |
307 uint32_t element_index = 0; | 307 uint32_t element_index = 0; |
308 if (key->ToArrayIndex(&element_index)) { | 308 if (key->IsSymbol()) { |
| 309 // If key is a symbol it is not an array element. |
| 310 Handle<String> name(String::cast(*key)); |
| 311 ASSERT(!name->AsArrayIndex(&element_index)); |
| 312 result = SetProperty(boilerplate, name, value, NONE); |
| 313 } else if (key->ToArrayIndex(&element_index)) { |
309 // Array index (uint32). | 314 // Array index (uint32). |
310 result = SetElement(boilerplate, element_index, value); | 315 result = SetElement(boilerplate, element_index, value); |
311 } else if (key->IsSymbol()) { | |
312 // The key is not an array index. | |
313 Handle<String> name(String::cast(*key)); | |
314 result = SetProperty(boilerplate, name, value, NONE); | |
315 } else { | 316 } else { |
316 // Non-uint32 number. | 317 // Non-uint32 number. |
317 ASSERT(key->IsNumber()); | 318 ASSERT(key->IsNumber()); |
318 double num = key->Number(); | 319 double num = key->Number(); |
319 char arr[100]; | 320 char arr[100]; |
320 Vector<char> buffer(arr, ARRAY_SIZE(arr)); | 321 Vector<char> buffer(arr, ARRAY_SIZE(arr)); |
321 const char* str = DoubleToCString(num, buffer); | 322 const char* str = DoubleToCString(num, buffer); |
322 Handle<String> name = Factory::NewStringFromAscii(CStrVector(str)); | 323 Handle<String> name = Factory::NewStringFromAscii(CStrVector(str)); |
323 result = SetProperty(boilerplate, name, value, NONE); | 324 result = SetProperty(boilerplate, name, value, NONE); |
324 } | 325 } |
(...skipping 10274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10599 } else { | 10600 } else { |
10600 // Handle last resort GC and make sure to allow future allocations | 10601 // Handle last resort GC and make sure to allow future allocations |
10601 // to grow the heap without causing GCs (if possible). | 10602 // to grow the heap without causing GCs (if possible). |
10602 Counters::gc_last_resort_from_js.Increment(); | 10603 Counters::gc_last_resort_from_js.Increment(); |
10603 Heap::CollectAllGarbage(false); | 10604 Heap::CollectAllGarbage(false); |
10604 } | 10605 } |
10605 } | 10606 } |
10606 | 10607 |
10607 | 10608 |
10608 } } // namespace v8::internal | 10609 } } // namespace v8::internal |
OLD | NEW |