Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(587)

Side by Side Diff: src/runtime.cc

Issue 11358234: Object.observe: Handle oldValue for elements with accessors properly. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/harmony/object-observe.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 static MaybeObject* GetOwnProperty(Isolate* isolate, 1084 static MaybeObject* GetOwnProperty(Isolate* isolate,
1085 Handle<JSObject> obj, 1085 Handle<JSObject> obj,
1086 Handle<String> name) { 1086 Handle<String> name) {
1087 Heap* heap = isolate->heap(); 1087 Heap* heap = isolate->heap();
1088 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); 1088 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE);
1089 Handle<JSArray> desc = isolate->factory()->NewJSArrayWithElements(elms); 1089 Handle<JSArray> desc = isolate->factory()->NewJSArrayWithElements(elms);
1090 LookupResult result(isolate); 1090 LookupResult result(isolate);
1091 // This could be an element. 1091 // This could be an element.
1092 uint32_t index; 1092 uint32_t index;
1093 if (name->AsArrayIndex(&index)) { 1093 if (name->AsArrayIndex(&index)) {
1094 switch (obj->GetLocalElementType(index)) { 1094 switch (obj->GetLocalElementKind(index)) {
1095 case JSObject::UNDEFINED_ELEMENT: 1095 case JSObject::UNDEFINED_ELEMENT:
1096 return heap->undefined_value(); 1096 return heap->undefined_value();
1097 1097
1098 case JSObject::STRING_CHARACTER_ELEMENT: { 1098 case JSObject::STRING_CHARACTER_ELEMENT: {
1099 // Special handling of string objects according to ECMAScript 5 1099 // Special handling of string objects according to ECMAScript 5
1100 // 15.5.5.2. Note that this might be a string object with elements 1100 // 15.5.5.2. Note that this might be a string object with elements
1101 // other than the actual string value. This is covered by the 1101 // other than the actual string value. This is covered by the
1102 // subsequent cases. 1102 // subsequent cases.
1103 Handle<JSValue> js_value = Handle<JSValue>::cast(obj); 1103 Handle<JSValue> js_value = Handle<JSValue>::cast(obj);
1104 Handle<String> str(String::cast(js_value->value())); 1104 Handle<String> str(String::cast(js_value->value()));
(...skipping 3615 matching lines...) Expand 10 before | Expand all | Expand 10 after
4720 4720
4721 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) { 4721 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) {
4722 NoHandleAllocation ha; 4722 NoHandleAllocation ha;
4723 ASSERT(args.length() == 2); 4723 ASSERT(args.length() == 2);
4724 4724
4725 CONVERT_ARG_CHECKED(JSObject, object, 0); 4725 CONVERT_ARG_CHECKED(JSObject, object, 0);
4726 CONVERT_ARG_CHECKED(String, key, 1); 4726 CONVERT_ARG_CHECKED(String, key, 1);
4727 4727
4728 uint32_t index; 4728 uint32_t index;
4729 if (key->AsArrayIndex(&index)) { 4729 if (key->AsArrayIndex(&index)) {
4730 JSObject::LocalElementType type = object->GetLocalElementType(index); 4730 JSObject::LocalElementKind type = object->GetLocalElementKind(index);
4731 switch (type) { 4731 switch (type) {
4732 case JSObject::UNDEFINED_ELEMENT: 4732 case JSObject::UNDEFINED_ELEMENT:
4733 case JSObject::STRING_CHARACTER_ELEMENT: 4733 case JSObject::STRING_CHARACTER_ELEMENT:
4734 return isolate->heap()->false_value(); 4734 return isolate->heap()->false_value();
4735 case JSObject::INTERCEPTED_ELEMENT: 4735 case JSObject::INTERCEPTED_ELEMENT:
4736 case JSObject::FAST_ELEMENT: 4736 case JSObject::FAST_ELEMENT:
4737 return isolate->heap()->true_value(); 4737 return isolate->heap()->true_value();
4738 case JSObject::DICTIONARY_ELEMENT: { 4738 case JSObject::DICTIONARY_ELEMENT: {
4739 if (object->IsJSGlobalProxy()) { 4739 if (object->IsJSGlobalProxy()) {
4740 Object* proto = object->GetPrototype(); 4740 Object* proto = object->GetPrototype();
(...skipping 8576 matching lines...) Expand 10 before | Expand all | Expand 10 after
13317 // Handle last resort GC and make sure to allow future allocations 13317 // Handle last resort GC and make sure to allow future allocations
13318 // to grow the heap without causing GCs (if possible). 13318 // to grow the heap without causing GCs (if possible).
13319 isolate->counters()->gc_last_resort_from_js()->Increment(); 13319 isolate->counters()->gc_last_resort_from_js()->Increment();
13320 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13320 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13321 "Runtime::PerformGC"); 13321 "Runtime::PerformGC");
13322 } 13322 }
13323 } 13323 }
13324 13324
13325 13325
13326 } } // namespace v8::internal 13326 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/harmony/object-observe.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698