| OLD | NEW |
| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 Handle<Object> value(constant_properties->get(index+1), isolate); | 258 Handle<Object> value(constant_properties->get(index+1), isolate); |
| 259 if (value->IsFixedArray()) { | 259 if (value->IsFixedArray()) { |
| 260 // The value contains the constant_properties of a | 260 // The value contains the constant_properties of a |
| 261 // simple object or array literal. | 261 // simple object or array literal. |
| 262 Handle<FixedArray> array = Handle<FixedArray>::cast(value); | 262 Handle<FixedArray> array = Handle<FixedArray>::cast(value); |
| 263 value = CreateLiteralBoilerplate(isolate, literals, array); | 263 value = CreateLiteralBoilerplate(isolate, literals, array); |
| 264 if (value.is_null()) return value; | 264 if (value.is_null()) return value; |
| 265 } | 265 } |
| 266 Handle<Object> result; | 266 Handle<Object> result; |
| 267 uint32_t element_index = 0; | 267 uint32_t element_index = 0; |
| 268 JSReceiver::StoreMode mode = value->IsJSObject() |
| 269 ? JSReceiver::FORCE_FIELD |
| 270 : JSReceiver::ALLOW_AS_CONSTANT; |
| 268 if (key->IsInternalizedString()) { | 271 if (key->IsInternalizedString()) { |
| 269 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { | 272 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { |
| 270 // Array index as string (uint32). | 273 // Array index as string (uint32). |
| 271 result = JSObject::SetOwnElement( | 274 result = JSObject::SetOwnElement( |
| 272 boilerplate, element_index, value, kNonStrictMode); | 275 boilerplate, element_index, value, kNonStrictMode); |
| 273 } else { | 276 } else { |
| 274 Handle<String> name(String::cast(*key)); | 277 Handle<String> name(String::cast(*key)); |
| 275 ASSERT(!name->AsArrayIndex(&element_index)); | 278 ASSERT(!name->AsArrayIndex(&element_index)); |
| 276 result = JSObject::SetLocalPropertyIgnoreAttributes( | 279 result = JSObject::SetLocalPropertyIgnoreAttributes( |
| 277 boilerplate, name, value, NONE); | 280 boilerplate, name, value, NONE, |
| 281 Object::OPTIMAL_REPRESENTATION, mode); |
| 278 } | 282 } |
| 279 } else if (key->ToArrayIndex(&element_index)) { | 283 } else if (key->ToArrayIndex(&element_index)) { |
| 280 // Array index (uint32). | 284 // Array index (uint32). |
| 281 result = JSObject::SetOwnElement( | 285 result = JSObject::SetOwnElement( |
| 282 boilerplate, element_index, value, kNonStrictMode); | 286 boilerplate, element_index, value, kNonStrictMode); |
| 283 } else { | 287 } else { |
| 284 // Non-uint32 number. | 288 // Non-uint32 number. |
| 285 ASSERT(key->IsNumber()); | 289 ASSERT(key->IsNumber()); |
| 286 double num = key->Number(); | 290 double num = key->Number(); |
| 287 char arr[100]; | 291 char arr[100]; |
| 288 Vector<char> buffer(arr, ARRAY_SIZE(arr)); | 292 Vector<char> buffer(arr, ARRAY_SIZE(arr)); |
| 289 const char* str = DoubleToCString(num, buffer); | 293 const char* str = DoubleToCString(num, buffer); |
| 290 Handle<String> name = | 294 Handle<String> name = |
| 291 isolate->factory()->NewStringFromAscii(CStrVector(str)); | 295 isolate->factory()->NewStringFromAscii(CStrVector(str)); |
| 292 result = JSObject::SetLocalPropertyIgnoreAttributes( | 296 result = JSObject::SetLocalPropertyIgnoreAttributes( |
| 293 boilerplate, name, value, NONE); | 297 boilerplate, name, value, NONE, |
| 298 Object::OPTIMAL_REPRESENTATION, mode); |
| 294 } | 299 } |
| 295 // If setting the property on the boilerplate throws an | 300 // If setting the property on the boilerplate throws an |
| 296 // exception, the exception is converted to an empty handle in | 301 // exception, the exception is converted to an empty handle in |
| 297 // the handle based operations. In that case, we need to | 302 // the handle based operations. In that case, we need to |
| 298 // convert back to an exception. | 303 // convert back to an exception. |
| 299 if (result.is_null()) return result; | 304 if (result.is_null()) return result; |
| 300 } | 305 } |
| 301 | 306 |
| 302 // Transform to fast properties if necessary. For object literals with | 307 // Transform to fast properties if necessary. For object literals with |
| 303 // containing function literals we defer this operation until after all | 308 // containing function literals we defer this operation until after all |
| (...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2196 properties->set(index, *value); | 2201 properties->set(index, *value); |
| 2197 } | 2202 } |
| 2198 } else if (lookup.IsNormal()) { | 2203 } else if (lookup.IsNormal()) { |
| 2199 if (global->GetNormalizedProperty(&lookup)->IsTheHole() || | 2204 if (global->GetNormalizedProperty(&lookup)->IsTheHole() || |
| 2200 !lookup.IsReadOnly()) { | 2205 !lookup.IsReadOnly()) { |
| 2201 HandleScope scope(isolate); | 2206 HandleScope scope(isolate); |
| 2202 JSObject::SetNormalizedProperty(Handle<JSObject>(global), &lookup, value); | 2207 JSObject::SetNormalizedProperty(Handle<JSObject>(global), &lookup, value); |
| 2203 } | 2208 } |
| 2204 } else { | 2209 } else { |
| 2205 // Ignore re-initialization of constants that have already been | 2210 // Ignore re-initialization of constants that have already been |
| 2206 // assigned a function value. | 2211 // assigned a constant value. |
| 2207 ASSERT(lookup.IsReadOnly() && lookup.IsConstantFunction()); | 2212 ASSERT(lookup.IsReadOnly() && lookup.IsConstant()); |
| 2208 } | 2213 } |
| 2209 | 2214 |
| 2210 // Use the set value as the result of the operation. | 2215 // Use the set value as the result of the operation. |
| 2211 return *value; | 2216 return *value; |
| 2212 } | 2217 } |
| 2213 | 2218 |
| 2214 | 2219 |
| 2215 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstContextSlot) { | 2220 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstContextSlot) { |
| 2216 HandleScope scope(isolate); | 2221 HandleScope scope(isolate); |
| 2217 ASSERT(args.length() == 3); | 2222 ASSERT(args.length() == 3); |
| (...skipping 2744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4962 LookupResult lookup(isolate); | 4967 LookupResult lookup(isolate); |
| 4963 object->LookupRealNamedProperty(*key, &lookup); | 4968 object->LookupRealNamedProperty(*key, &lookup); |
| 4964 if (!lookup.IsFound()) return isolate->heap()->undefined_value(); | 4969 if (!lookup.IsFound()) return isolate->heap()->undefined_value(); |
| 4965 switch (lookup.type()) { | 4970 switch (lookup.type()) { |
| 4966 case NORMAL: | 4971 case NORMAL: |
| 4967 return lookup.holder()->GetNormalizedProperty(&lookup); | 4972 return lookup.holder()->GetNormalizedProperty(&lookup); |
| 4968 case FIELD: | 4973 case FIELD: |
| 4969 return lookup.holder()->FastPropertyAt( | 4974 return lookup.holder()->FastPropertyAt( |
| 4970 lookup.representation(), | 4975 lookup.representation(), |
| 4971 lookup.GetFieldIndex().field_index()); | 4976 lookup.GetFieldIndex().field_index()); |
| 4972 case CONSTANT_FUNCTION: | 4977 case CONSTANT: |
| 4973 return lookup.GetConstantFunction(); | 4978 return lookup.GetConstant(); |
| 4974 case CALLBACKS: | 4979 case CALLBACKS: |
| 4975 case HANDLER: | 4980 case HANDLER: |
| 4976 case INTERCEPTOR: | 4981 case INTERCEPTOR: |
| 4977 case TRANSITION: | 4982 case TRANSITION: |
| 4978 return isolate->heap()->undefined_value(); | 4983 return isolate->heap()->undefined_value(); |
| 4979 case NONEXISTENT: | 4984 case NONEXISTENT: |
| 4980 UNREACHABLE(); | 4985 UNREACHABLE(); |
| 4981 } | 4986 } |
| 4982 return isolate->heap()->undefined_value(); | 4987 return isolate->heap()->undefined_value(); |
| 4983 } | 4988 } |
| (...skipping 5563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10547 MaybeObject* maybe_value = | 10552 MaybeObject* maybe_value = |
| 10548 JSObject::cast(result->holder())->FastPropertyAt( | 10553 JSObject::cast(result->holder())->FastPropertyAt( |
| 10549 result->representation(), | 10554 result->representation(), |
| 10550 result->GetFieldIndex().field_index()); | 10555 result->GetFieldIndex().field_index()); |
| 10551 if (!maybe_value->To(&value)) return maybe_value; | 10556 if (!maybe_value->To(&value)) return maybe_value; |
| 10552 if (value->IsTheHole()) { | 10557 if (value->IsTheHole()) { |
| 10553 return heap->undefined_value(); | 10558 return heap->undefined_value(); |
| 10554 } | 10559 } |
| 10555 return value; | 10560 return value; |
| 10556 } | 10561 } |
| 10557 case CONSTANT_FUNCTION: | 10562 case CONSTANT: |
| 10558 return result->GetConstantFunction(); | 10563 return result->GetConstant(); |
| 10559 case CALLBACKS: { | 10564 case CALLBACKS: { |
| 10560 Object* structure = result->GetCallbackObject(); | 10565 Object* structure = result->GetCallbackObject(); |
| 10561 if (structure->IsForeign() || structure->IsAccessorInfo()) { | 10566 if (structure->IsForeign() || structure->IsAccessorInfo()) { |
| 10562 MaybeObject* maybe_value = result->holder()->GetPropertyWithCallback( | 10567 MaybeObject* maybe_value = result->holder()->GetPropertyWithCallback( |
| 10563 receiver, structure, name); | 10568 receiver, structure, name); |
| 10564 if (!maybe_value->ToObject(&value)) { | 10569 if (!maybe_value->ToObject(&value)) { |
| 10565 if (maybe_value->IsRetryAfterGC()) return maybe_value; | 10570 if (maybe_value->IsRetryAfterGC()) return maybe_value; |
| 10566 ASSERT(maybe_value->IsException()); | 10571 ASSERT(maybe_value->IsException()); |
| 10567 maybe_value = heap->isolate()->pending_exception(); | 10572 maybe_value = heap->isolate()->pending_exception(); |
| 10568 heap->isolate()->clear_pending_exception(); | 10573 heap->isolate()->clear_pending_exception(); |
| (...skipping 3410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13979 // Handle last resort GC and make sure to allow future allocations | 13984 // Handle last resort GC and make sure to allow future allocations |
| 13980 // to grow the heap without causing GCs (if possible). | 13985 // to grow the heap without causing GCs (if possible). |
| 13981 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13986 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13982 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13987 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13983 "Runtime::PerformGC"); | 13988 "Runtime::PerformGC"); |
| 13984 } | 13989 } |
| 13985 } | 13990 } |
| 13986 | 13991 |
| 13987 | 13992 |
| 13988 } } // namespace v8::internal | 13993 } } // namespace v8::internal |
| OLD | NEW |