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

Unified Diff: src/runtime.cc

Issue 6445: This change removes the %AddProperty native JavaScript function from V8.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.h ('k') | src/string.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
===================================================================
--- src/runtime.cc (revision 423)
+++ src/runtime.cc (working copy)
@@ -504,11 +504,14 @@
// there, we add the property and take special precautions to always
// add it as a local property even in case of callbacks in the
// prototype chain (this rules out using SetProperty).
+ // We have IgnoreAttributesAndSetLocalProperty for this.
LookupResult lookup;
global->LocalLookup(*name, &lookup);
if (!lookup.IsProperty()) {
Object* value = (assign) ? args[1] : Heap::undefined_value();
- return global->AddProperty(*name, value, attributes);
+ return global->IgnoreAttributesAndSetLocalProperty(*name,
+ value,
+ attributes);
}
// Determine if this is a redeclaration of something read-only.
@@ -568,10 +571,13 @@
// there, we add the property and take special precautions to always
// add it as a local property even in case of callbacks in the
// prototype chain (this rules out using SetProperty).
+ // We use IgnoreAttributesAndSetLocalProperty instead
LookupResult lookup;
global->LocalLookup(*name, &lookup);
if (!lookup.IsProperty()) {
- return global->AddProperty(*name, *value, attributes);
+ return global->IgnoreAttributesAndSetLocalProperty(*name,
+ *value,
+ attributes);
}
// Determine if this is a redeclaration of something not
@@ -1377,23 +1383,6 @@
}
-static Object* Runtime_AddProperty(Arguments args) {
- NoHandleAllocation ha;
- ASSERT(args.length() == 4);
-
- CONVERT_CHECKED(JSObject, object, args[0]);
- CONVERT_CHECKED(String, name, args[1]);
- RUNTIME_ASSERT(!object->HasLocalProperty(name));
- CONVERT_CHECKED(Smi, attr_obj, args[3]);
-
- int attr = attr_obj->value();
- RUNTIME_ASSERT((attr & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
- PropertyAttributes attributes = static_cast<PropertyAttributes>(attr);
-
- return object->AddProperty(name, args[2], attributes);
-}
-
-
static Object* Runtime_SetProperty(Arguments args) {
NoHandleAllocation ha;
RUNTIME_ASSERT(args.length() == 3 || args.length() == 4);
@@ -1406,10 +1395,11 @@
PropertyAttributes attributes = NONE;
if (args.length() == 4) {
CONVERT_CHECKED(Smi, value_obj, args[3]);
- int value = value_obj->value();
+ int unchecked_value = value_obj->value();
// Only attribute bits should be set.
- ASSERT((value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
- attributes = static_cast<PropertyAttributes>(value);
+ RUNTIME_ASSERT(
+ (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
+ attributes = static_cast<PropertyAttributes>(unchecked_value);
}
return Runtime::SetObjectProperty(object, key, value, attributes);
}
@@ -1419,12 +1409,22 @@
// exist, it will be added with attributes NONE.
static Object* Runtime_IgnoreAttributesAndSetProperty(Arguments args) {
NoHandleAllocation ha;
- ASSERT(args.length() == 3);
-
+ RUNTIME_ASSERT(args.length() == 3 || args.length() == 4);
CONVERT_CHECKED(JSObject, object, args[0]);
CONVERT_CHECKED(String, name, args[1]);
+ // Compute attributes.
+ PropertyAttributes attributes = NONE;
+ if (args.length() == 4) {
+ CONVERT_CHECKED(Smi, value_obj, args[3]);
+ int unchecked_value = value_obj->value();
+ // Only attribute bits should be set.
+ RUNTIME_ASSERT(
+ (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
+ attributes = static_cast<PropertyAttributes>(unchecked_value);
+ }
- return object->IgnoreAttributesAndSetLocalProperty(name, args[2], NONE);
+ return object->
+ IgnoreAttributesAndSetLocalProperty(name, args[2], attributes);
}
« no previous file with comments | « src/runtime.h ('k') | src/string.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698