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

Side by Side Diff: src/runtime.cc

Issue 463963002: Always assume SetOwnPropertyIgnoreAttributes to be CERTAINLY_NOT_FROM_KEYED (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | « src/runtime.h ('k') | no next file » | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 5024 matching lines...) Expand 10 before | Expand all | Expand 10 after
5035 // map. 5035 // map.
5036 if (lookup.IsFound() && 5036 if (lookup.IsFound() &&
5037 (attr != lookup.GetAttributes() || lookup.IsPropertyCallbacks())) { 5037 (attr != lookup.GetAttributes() || lookup.IsPropertyCallbacks())) {
5038 // Use IgnoreAttributes version since a readonly property may be 5038 // Use IgnoreAttributes version since a readonly property may be
5039 // overridden and SetProperty does not allow this. 5039 // overridden and SetProperty does not allow this.
5040 Handle<Object> result; 5040 Handle<Object> result;
5041 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 5041 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
5042 isolate, result, 5042 isolate, result,
5043 JSObject::SetOwnPropertyIgnoreAttributes( 5043 JSObject::SetOwnPropertyIgnoreAttributes(
5044 js_object, name, obj_value, attr, 5044 js_object, name, obj_value, attr,
5045 JSReceiver::MAY_BE_STORE_FROM_KEYED, JSObject::DONT_FORCE_FIELD)); 5045 JSObject::DONT_FORCE_FIELD));
5046 return *result; 5046 return *result;
5047 } 5047 }
5048 5048
5049 Handle<Object> result; 5049 Handle<Object> result;
5050 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 5050 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
5051 isolate, result, 5051 isolate, result,
5052 Runtime::DefineObjectProperty( 5052 Runtime::DefineObjectProperty(js_object, name, obj_value, attr));
5053 js_object, name, obj_value, attr,
5054 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED));
5055 return *result; 5053 return *result;
5056 } 5054 }
5057 5055
5058 5056
5059 // Return property without being observable by accessors or interceptors. 5057 // Return property without being observable by accessors or interceptors.
5060 RUNTIME_FUNCTION(Runtime_GetDataProperty) { 5058 RUNTIME_FUNCTION(Runtime_GetDataProperty) {
5061 HandleScope scope(isolate); 5059 HandleScope scope(isolate);
5062 DCHECK(args.length() == 2); 5060 DCHECK(args.length() == 2);
5063 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 5061 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
5064 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); 5062 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
5156 // TODO(verwaest): Support non-JSObject receivers. 5154 // TODO(verwaest): Support non-JSObject receivers.
5157 if (!object->IsJSObject()) return value; 5155 if (!object->IsJSObject()) return value;
5158 Handle<JSObject> js_object = Handle<JSObject>::cast(object); 5156 Handle<JSObject> js_object = Handle<JSObject>::cast(object);
5159 return JSObject::SetElement(js_object, index, value, NONE, strict_mode, 5157 return JSObject::SetElement(js_object, index, value, NONE, strict_mode,
5160 true, SET_PROPERTY); 5158 true, SET_PROPERTY);
5161 } 5159 }
5162 return Object::SetProperty(object, name, value, strict_mode); 5160 return Object::SetProperty(object, name, value, strict_mode);
5163 } 5161 }
5164 5162
5165 5163
5166 MaybeHandle<Object> Runtime::DefineObjectProperty( 5164 MaybeHandle<Object> Runtime::DefineObjectProperty(Handle<JSObject> js_object,
5167 Handle<JSObject> js_object, 5165 Handle<Object> key,
5168 Handle<Object> key, 5166 Handle<Object> value,
5169 Handle<Object> value, 5167 PropertyAttributes attr) {
5170 PropertyAttributes attr,
5171 JSReceiver::StoreFromKeyed store_from_keyed) {
5172 Isolate* isolate = js_object->GetIsolate(); 5168 Isolate* isolate = js_object->GetIsolate();
5173 // Check if the given key is an array index. 5169 // Check if the given key is an array index.
5174 uint32_t index; 5170 uint32_t index;
5175 if (key->ToArrayIndex(&index)) { 5171 if (key->ToArrayIndex(&index)) {
5176 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters 5172 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters
5177 // of a string using [] notation. We need to support this too in 5173 // of a string using [] notation. We need to support this too in
5178 // JavaScript. 5174 // JavaScript.
5179 // In the case of a String object we just need to redirect the assignment to 5175 // In the case of a String object we just need to redirect the assignment to
5180 // the underlying string if the index is in range. Since the underlying 5176 // the underlying string if the index is in range. Since the underlying
5181 // string does nothing with the assignment then we can ignore such 5177 // string does nothing with the assignment then we can ignore such
5182 // assignments. 5178 // assignments.
5183 if (js_object->IsStringObjectWithCharacterAt(index)) { 5179 if (js_object->IsStringObjectWithCharacterAt(index)) {
5184 return value; 5180 return value;
5185 } 5181 }
5186 5182
5187 return JSObject::SetElement(js_object, index, value, attr, 5183 return JSObject::SetElement(js_object, index, value, attr,
5188 SLOPPY, false, DEFINE_PROPERTY); 5184 SLOPPY, false, DEFINE_PROPERTY);
5189 } 5185 }
5190 5186
5191 if (key->IsName()) { 5187 if (key->IsName()) {
5192 Handle<Name> name = Handle<Name>::cast(key); 5188 Handle<Name> name = Handle<Name>::cast(key);
5193 if (name->AsArrayIndex(&index)) { 5189 if (name->AsArrayIndex(&index)) {
5194 return JSObject::SetElement(js_object, index, value, attr, 5190 return JSObject::SetElement(js_object, index, value, attr,
5195 SLOPPY, false, DEFINE_PROPERTY); 5191 SLOPPY, false, DEFINE_PROPERTY);
5196 } else { 5192 } else {
5197 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name)); 5193 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name));
5198 return JSObject::SetOwnPropertyIgnoreAttributes(js_object, name, value, 5194 return JSObject::SetOwnPropertyIgnoreAttributes(js_object, name, value,
5199 attr, store_from_keyed); 5195 attr);
5200 } 5196 }
5201 } 5197 }
5202 5198
5203 // Call-back into JavaScript to convert the key to a string. 5199 // Call-back into JavaScript to convert the key to a string.
5204 Handle<Object> converted; 5200 Handle<Object> converted;
5205 ASSIGN_RETURN_ON_EXCEPTION( 5201 ASSIGN_RETURN_ON_EXCEPTION(
5206 isolate, converted, Execution::ToString(isolate, key), Object); 5202 isolate, converted, Execution::ToString(isolate, key), Object);
5207 Handle<String> name = Handle<String>::cast(converted); 5203 Handle<String> name = Handle<String>::cast(converted);
5208 5204
5209 if (name->AsArrayIndex(&index)) { 5205 if (name->AsArrayIndex(&index)) {
5210 return JSObject::SetElement(js_object, index, value, attr, 5206 return JSObject::SetElement(js_object, index, value, attr,
5211 SLOPPY, false, DEFINE_PROPERTY); 5207 SLOPPY, false, DEFINE_PROPERTY);
5212 } else { 5208 } else {
5213 return JSObject::SetOwnPropertyIgnoreAttributes(js_object, name, value, 5209 return JSObject::SetOwnPropertyIgnoreAttributes(js_object, name, value,
5214 attr, store_from_keyed); 5210 attr);
5215 } 5211 }
5216 } 5212 }
5217 5213
5218 5214
5219 MaybeHandle<Object> Runtime::DeleteObjectProperty(Isolate* isolate, 5215 MaybeHandle<Object> Runtime::DeleteObjectProperty(Isolate* isolate,
5220 Handle<JSReceiver> receiver, 5216 Handle<JSReceiver> receiver,
5221 Handle<Object> key, 5217 Handle<Object> key,
5222 JSReceiver::DeleteMode mode) { 5218 JSReceiver::DeleteMode mode) {
5223 // Check if the given key is an array index. 5219 // Check if the given key is an array index.
5224 uint32_t index; 5220 uint32_t index;
(...skipping 10401 matching lines...) Expand 10 before | Expand all | Expand 10 after
15626 } 15622 }
15627 return NULL; 15623 return NULL;
15628 } 15624 }
15629 15625
15630 15626
15631 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15627 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15632 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15628 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15633 } 15629 }
15634 15630
15635 } } // namespace v8::internal 15631 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698