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 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1523 // Declaring a const context slot is a conflicting declaration if | 1523 // Declaring a const context slot is a conflicting declaration if |
1524 // there is a callback with that name in a prototype. It is | 1524 // there is a callback with that name in a prototype. It is |
1525 // allowed to introduce const variables in | 1525 // allowed to introduce const variables in |
1526 // JSContextExtensionObjects. They are treated specially in | 1526 // JSContextExtensionObjects. They are treated specially in |
1527 // SetProperty and no setters are invoked for those since they are | 1527 // SetProperty and no setters are invoked for those since they are |
1528 // not real JSObjects. | 1528 // not real JSObjects. |
1529 if (initial_value->IsTheHole() && | 1529 if (initial_value->IsTheHole() && |
1530 !object->IsJSContextExtensionObject()) { | 1530 !object->IsJSContextExtensionObject()) { |
1531 LookupResult lookup(isolate); | 1531 LookupResult lookup(isolate); |
1532 object->Lookup(*name, &lookup); | 1532 object->Lookup(*name, &lookup); |
1533 if (lookup.IsCallbacks()) { | 1533 if (lookup.IsPropertyCallbacks()) { |
1534 return ThrowRedeclarationError(isolate, "const", name); | 1534 return ThrowRedeclarationError(isolate, "const", name); |
1535 } | 1535 } |
1536 } | 1536 } |
1537 if (object->IsJSGlobalObject()) { | 1537 if (object->IsJSGlobalObject()) { |
1538 // Define own property on the global object. | 1538 // Define own property on the global object. |
1539 RETURN_IF_EMPTY_HANDLE(isolate, | 1539 RETURN_IF_EMPTY_HANDLE(isolate, |
1540 JSObject::SetLocalPropertyIgnoreAttributes(object, name, value, mode)); | 1540 JSObject::SetLocalPropertyIgnoreAttributes(object, name, value, mode)); |
1541 } else { | 1541 } else { |
1542 RETURN_IF_EMPTY_HANDLE(isolate, | 1542 RETURN_IF_EMPTY_HANDLE(isolate, |
1543 JSReceiver::SetProperty(object, name, value, mode, kNonStrictMode)); | 1543 JSReceiver::SetProperty(object, name, value, mode, kNonStrictMode)); |
(...skipping 2980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4524 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); | 4524 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); |
4525 CONVERT_ARG_HANDLE_CHECKED(Object, obj_value, 2); | 4525 CONVERT_ARG_HANDLE_CHECKED(Object, obj_value, 2); |
4526 CONVERT_SMI_ARG_CHECKED(unchecked, 3); | 4526 CONVERT_SMI_ARG_CHECKED(unchecked, 3); |
4527 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 4527 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
4528 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); | 4528 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); |
4529 | 4529 |
4530 LookupResult result(isolate); | 4530 LookupResult result(isolate); |
4531 js_object->LocalLookupRealNamedProperty(*name, &result); | 4531 js_object->LocalLookupRealNamedProperty(*name, &result); |
4532 | 4532 |
4533 // Special case for callback properties. | 4533 // Special case for callback properties. |
4534 if (result.IsCallbacks()) { | 4534 if (result.IsPropertyCallbacks()) { |
4535 Object* callback = result.GetCallbackObject(); | 4535 Object* callback = result.GetCallbackObject(); |
4536 // To be compatible with Safari we do not change the value on API objects | 4536 // To be compatible with Safari we do not change the value on API objects |
4537 // in Object.defineProperty(). Firefox disagrees here, and actually changes | 4537 // in Object.defineProperty(). Firefox disagrees here, and actually changes |
4538 // the value. | 4538 // the value. |
4539 if (callback->IsAccessorInfo()) { | 4539 if (callback->IsAccessorInfo()) { |
4540 return isolate->heap()->undefined_value(); | 4540 return isolate->heap()->undefined_value(); |
4541 } | 4541 } |
4542 // Avoid redefining foreign callback as data property, just use the stored | 4542 // Avoid redefining foreign callback as data property, just use the stored |
4543 // setter to update the value instead. | 4543 // setter to update the value instead. |
4544 // TODO(mstarzinger): So far this only works if property attributes don't | 4544 // TODO(mstarzinger): So far this only works if property attributes don't |
(...skipping 9167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13712 // Handle last resort GC and make sure to allow future allocations | 13712 // Handle last resort GC and make sure to allow future allocations |
13713 // to grow the heap without causing GCs (if possible). | 13713 // to grow the heap without causing GCs (if possible). |
13714 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13714 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13715 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13715 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13716 "Runtime::PerformGC"); | 13716 "Runtime::PerformGC"); |
13717 } | 13717 } |
13718 } | 13718 } |
13719 | 13719 |
13720 | 13720 |
13721 } } // namespace v8::internal | 13721 } } // namespace v8::internal |
OLD | NEW |