| 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 7373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7384 | 7384 |
| 7385 int index; | 7385 int index; |
| 7386 PropertyAttributes attributes; | 7386 PropertyAttributes attributes; |
| 7387 ContextLookupFlags flags = FOLLOW_CHAINS; | 7387 ContextLookupFlags flags = FOLLOW_CHAINS; |
| 7388 Handle<Object> holder = context->Lookup(name, flags, &index, &attributes); | 7388 Handle<Object> holder = context->Lookup(name, flags, &index, &attributes); |
| 7389 | 7389 |
| 7390 if (index >= 0) { | 7390 if (index >= 0) { |
| 7391 if (holder->IsContext()) { | 7391 if (holder->IsContext()) { |
| 7392 // Ignore if read_only variable. | 7392 // Ignore if read_only variable. |
| 7393 if ((attributes & READ_ONLY) == 0) { | 7393 if ((attributes & READ_ONLY) == 0) { |
| 7394 Handle<Context>::cast(holder)->set(index, *value); | 7394 // Context is a fixed array and set cannot fail. |
| 7395 Context::cast(*holder)->set(index, *value); |
| 7395 } | 7396 } |
| 7396 } else { | 7397 } else { |
| 7397 ASSERT((attributes & READ_ONLY) == 0); | 7398 ASSERT((attributes & READ_ONLY) == 0); |
| 7398 Handle<JSObject>::cast(holder)->SetElement(index, *value)-> | 7399 Handle<Object> result = |
| 7399 ToObjectUnchecked(); | 7400 SetElement(Handle<JSObject>::cast(holder), index, value); |
| 7401 if (result.is_null()) { |
| 7402 ASSERT(Top::has_pending_exception()); |
| 7403 return Failure::Exception(); |
| 7404 } |
| 7400 } | 7405 } |
| 7401 return *value; | 7406 return *value; |
| 7402 } | 7407 } |
| 7403 | 7408 |
| 7404 // Slow case: The property is not in a FixedArray context. | 7409 // Slow case: The property is not in a FixedArray context. |
| 7405 // It is either in an JSObject extension context or it was not found. | 7410 // It is either in an JSObject extension context or it was not found. |
| 7406 Handle<JSObject> context_ext; | 7411 Handle<JSObject> context_ext; |
| 7407 | 7412 |
| 7408 if (!holder.is_null()) { | 7413 if (!holder.is_null()) { |
| 7409 // The property exists in the extension context. | 7414 // The property exists in the extension context. |
| 7410 context_ext = Handle<JSObject>::cast(holder); | 7415 context_ext = Handle<JSObject>::cast(holder); |
| 7411 } else { | 7416 } else { |
| 7412 // The property was not found. It needs to be stored in the global context. | 7417 // The property was not found. It needs to be stored in the global context. |
| 7413 ASSERT(attributes == ABSENT); | 7418 ASSERT(attributes == ABSENT); |
| 7414 attributes = NONE; | 7419 attributes = NONE; |
| 7415 context_ext = Handle<JSObject>(Top::context()->global()); | 7420 context_ext = Handle<JSObject>(Top::context()->global()); |
| 7416 } | 7421 } |
| 7417 | 7422 |
| 7418 // Set the property, but ignore if read_only variable on the context | 7423 // Set the property, but ignore if read_only variable on the context |
| 7419 // extension object itself. | 7424 // extension object itself. |
| 7420 if ((attributes & READ_ONLY) == 0 || | 7425 if ((attributes & READ_ONLY) == 0 || |
| 7421 (context_ext->GetLocalPropertyAttribute(*name) == ABSENT)) { | 7426 (context_ext->GetLocalPropertyAttribute(*name) == ABSENT)) { |
| 7422 Handle<Object> set = SetProperty(context_ext, name, value, NONE); | 7427 Handle<Object> result = SetProperty(context_ext, name, value, NONE); |
| 7423 if (set.is_null()) { | 7428 if (result.is_null()) { |
| 7424 // Failure::Exception is converted to a null handle in the | 7429 // Failure::Exception is converted to a null handle in the |
| 7425 // handle-based methods such as SetProperty. We therefore need | 7430 // handle-based methods such as SetProperty. We therefore need |
| 7426 // to convert null handles back to exceptions. | 7431 // to convert null handles back to exceptions. |
| 7427 ASSERT(Top::has_pending_exception()); | 7432 ASSERT(Top::has_pending_exception()); |
| 7428 return Failure::Exception(); | 7433 return Failure::Exception(); |
| 7429 } | 7434 } |
| 7430 } | 7435 } |
| 7431 return *value; | 7436 return *value; |
| 7432 } | 7437 } |
| 7433 | 7438 |
| (...skipping 3662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11096 } else { | 11101 } else { |
| 11097 // Handle last resort GC and make sure to allow future allocations | 11102 // Handle last resort GC and make sure to allow future allocations |
| 11098 // to grow the heap without causing GCs (if possible). | 11103 // to grow the heap without causing GCs (if possible). |
| 11099 Counters::gc_last_resort_from_js.Increment(); | 11104 Counters::gc_last_resort_from_js.Increment(); |
| 11100 Heap::CollectAllGarbage(false); | 11105 Heap::CollectAllGarbage(false); |
| 11101 } | 11106 } |
| 11102 } | 11107 } |
| 11103 | 11108 |
| 11104 | 11109 |
| 11105 } } // namespace v8::internal | 11110 } } // namespace v8::internal |
| OLD | NEW |