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

Side by Side Diff: src/runtime.cc

Issue 7562005: Revert "Make window.{undefined,NaN,Infinity} read-only" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 4 months 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 | « no previous file | src/v8natives.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 } 1165 }
1166 // Fall-through and introduce the absent property by using 1166 // Fall-through and introduce the absent property by using
1167 // SetProperty. 1167 // SetProperty.
1168 } else { 1168 } else {
1169 // For const properties, we treat a callback with this name 1169 // For const properties, we treat a callback with this name
1170 // even in the prototype as a conflicting declaration. 1170 // even in the prototype as a conflicting declaration.
1171 if (is_const_property && (lookup.type() == CALLBACKS)) { 1171 if (is_const_property && (lookup.type() == CALLBACKS)) {
1172 return ThrowRedeclarationError(isolate, "const", name); 1172 return ThrowRedeclarationError(isolate, "const", name);
1173 } 1173 }
1174 // Otherwise, we check for locally conflicting declarations. 1174 // Otherwise, we check for locally conflicting declarations.
1175 if (is_local && is_const_property) { 1175 if (is_local && (is_read_only || is_const_property)) {
1176 const char* type = (is_read_only) ? "const" : "var"; 1176 const char* type = (is_read_only) ? "const" : "var";
1177 return ThrowRedeclarationError(isolate, type, name); 1177 return ThrowRedeclarationError(isolate, type, name);
1178 } 1178 }
1179 // The property already exists without conflicting: Go to 1179 // The property already exists without conflicting: Go to
1180 // the next declaration. 1180 // the next declaration.
1181 continue; 1181 continue;
1182 } 1182 }
1183 } 1183 }
1184 } else { 1184 } else {
1185 // Copy the function and update its context. Use it as value. 1185 // Copy the function and update its context. Use it as value.
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 if (type == INTERCEPTOR) { 1399 if (type == INTERCEPTOR) {
1400 HandleScope handle_scope(isolate); 1400 HandleScope handle_scope(isolate);
1401 Handle<JSObject> holder(real_holder); 1401 Handle<JSObject> holder(real_holder);
1402 PropertyAttributes intercepted = holder->GetPropertyAttribute(*name); 1402 PropertyAttributes intercepted = holder->GetPropertyAttribute(*name);
1403 real_holder = *holder; 1403 real_holder = *holder;
1404 if (intercepted == ABSENT) { 1404 if (intercepted == ABSENT) {
1405 // The interceptor claims the property isn't there. We need to 1405 // The interceptor claims the property isn't there. We need to
1406 // make sure to introduce it. 1406 // make sure to introduce it.
1407 found = false; 1407 found = false;
1408 } else if ((intercepted & READ_ONLY) != 0) { 1408 } else if ((intercepted & READ_ONLY) != 0) {
1409 // The property is present, but read-only, so we ignore the 1409 // The property is present, but read-only. Since we're trying to
1410 // redeclaration. However if we found readonly property 1410 // overwrite it with a variable declaration we must throw a
1411 // re-declaration error. However if we found readonly property
1411 // on one of hidden prototypes, just shadow it. 1412 // on one of hidden prototypes, just shadow it.
1412 if (real_holder != isolate->context()->global()) break; 1413 if (real_holder != isolate->context()->global()) break;
1413 return isolate->heap()->undefined_value(); 1414 return ThrowRedeclarationError(isolate, "const", name);
1414 } 1415 }
1415 } 1416 }
1416 1417
1417 if (found && !assign) { 1418 if (found && !assign) {
1418 // The global property is there and we're not assigning any value 1419 // The global property is there and we're not assigning any value
1419 // to it. Just return. 1420 // to it. Just return.
1420 return isolate->heap()->undefined_value(); 1421 return isolate->heap()->undefined_value();
1421 } 1422 }
1422 1423
1423 // Assign the value (or undefined) to the property. 1424 // Assign the value (or undefined) to the property.
(...skipping 11342 matching lines...) Expand 10 before | Expand all | Expand 10 after
12766 } else { 12767 } else {
12767 // Handle last resort GC and make sure to allow future allocations 12768 // Handle last resort GC and make sure to allow future allocations
12768 // to grow the heap without causing GCs (if possible). 12769 // to grow the heap without causing GCs (if possible).
12769 isolate->counters()->gc_last_resort_from_js()->Increment(); 12770 isolate->counters()->gc_last_resort_from_js()->Increment();
12770 isolate->heap()->CollectAllGarbage(false); 12771 isolate->heap()->CollectAllGarbage(false);
12771 } 12772 }
12772 } 12773 }
12773 12774
12774 12775
12775 } } // namespace v8::internal 12776 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698