| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 &is_result_from_cache); | 154 &is_result_from_cache); |
| 155 | 155 |
| 156 Handle<JSObject> boilerplate = Factory::NewJSObjectFromMap(map); | 156 Handle<JSObject> boilerplate = Factory::NewJSObjectFromMap(map); |
| 157 { // Add the constant properties to the boilerplate. | 157 { // Add the constant properties to the boilerplate. |
| 158 int length = constant_properties->length(); | 158 int length = constant_properties->length(); |
| 159 OptimizedObjectForAddingMultipleProperties opt(boilerplate, | 159 OptimizedObjectForAddingMultipleProperties opt(boilerplate, |
| 160 !is_result_from_cache); | 160 !is_result_from_cache); |
| 161 for (int index = 0; index < length; index +=2) { | 161 for (int index = 0; index < length; index +=2) { |
| 162 Handle<Object> key(constant_properties->get(index+0)); | 162 Handle<Object> key(constant_properties->get(index+0)); |
| 163 Handle<Object> value(constant_properties->get(index+1)); | 163 Handle<Object> value(constant_properties->get(index+1)); |
| 164 Handle<Object> result; |
| 164 uint32_t element_index = 0; | 165 uint32_t element_index = 0; |
| 165 if (key->IsSymbol()) { | 166 if (key->IsSymbol()) { |
| 166 // If key is a symbol it is not an array element. | 167 // If key is a symbol it is not an array element. |
| 167 Handle<String> name(String::cast(*key)); | 168 Handle<String> name(String::cast(*key)); |
| 168 ASSERT(!name->AsArrayIndex(&element_index)); | 169 ASSERT(!name->AsArrayIndex(&element_index)); |
| 169 SetProperty(boilerplate, name, value, NONE); | 170 result = SetProperty(boilerplate, name, value, NONE); |
| 170 } else if (Array::IndexFromObject(*key, &element_index)) { | 171 } else if (Array::IndexFromObject(*key, &element_index)) { |
| 171 // Array index (uint32). | 172 // Array index (uint32). |
| 172 SetElement(boilerplate, element_index, value); | 173 result = SetElement(boilerplate, element_index, value); |
| 173 } else { | 174 } else { |
| 174 // Non-uint32 number. | 175 // Non-uint32 number. |
| 175 ASSERT(key->IsNumber()); | 176 ASSERT(key->IsNumber()); |
| 176 double num = key->Number(); | 177 double num = key->Number(); |
| 177 char arr[100]; | 178 char arr[100]; |
| 178 Vector<char> buffer(arr, ARRAY_SIZE(arr)); | 179 Vector<char> buffer(arr, ARRAY_SIZE(arr)); |
| 179 const char* str = DoubleToCString(num, buffer); | 180 const char* str = DoubleToCString(num, buffer); |
| 180 Handle<String> name = Factory::NewStringFromAscii(CStrVector(str)); | 181 Handle<String> name = Factory::NewStringFromAscii(CStrVector(str)); |
| 181 SetProperty(boilerplate, name, value, NONE); | 182 result = SetProperty(boilerplate, name, value, NONE); |
| 182 } | 183 } |
| 184 // If setting the property on the boilerplate throws an |
| 185 // exception, the exception is converted to an empty handle in |
| 186 // the handle based operations. In that case, we need to |
| 187 // convert back to an exception. |
| 188 if (result.is_null()) return Failure::Exception(); |
| 183 } | 189 } |
| 184 } | 190 } |
| 185 | 191 |
| 186 // Update the functions literal and return the boilerplate. | 192 // Update the functions literal and return the boilerplate. |
| 187 literals->set(literals_index, *boilerplate); | 193 literals->set(literals_index, *boilerplate); |
| 188 | 194 |
| 189 return *boilerplate; | 195 return *boilerplate; |
| 190 } | 196 } |
| 191 | 197 |
| 192 | 198 |
| (...skipping 5895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6088 } else { | 6094 } else { |
| 6089 // Handle last resort GC and make sure to allow future allocations | 6095 // Handle last resort GC and make sure to allow future allocations |
| 6090 // to grow the heap without causing GCs (if possible). | 6096 // to grow the heap without causing GCs (if possible). |
| 6091 Counters::gc_last_resort_from_js.Increment(); | 6097 Counters::gc_last_resort_from_js.Increment(); |
| 6092 Heap::CollectAllGarbage(); | 6098 Heap::CollectAllGarbage(); |
| 6093 } | 6099 } |
| 6094 } | 6100 } |
| 6095 | 6101 |
| 6096 | 6102 |
| 6097 } } // namespace v8::internal | 6103 } } // namespace v8::internal |
| OLD | NEW |