OLD | NEW |
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 "v8.h" | 8 #include "v8.h" |
9 | 9 |
10 #include "accessors.h" | 10 #include "accessors.h" |
(...skipping 5257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5268 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5268 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
5269 isolate, result, | 5269 isolate, result, |
5270 JSObject::SetLocalPropertyIgnoreAttributes( | 5270 JSObject::SetLocalPropertyIgnoreAttributes( |
5271 js_object, name, obj_value, attr)); | 5271 js_object, name, obj_value, attr)); |
5272 return *result; | 5272 return *result; |
5273 } | 5273 } |
5274 | 5274 |
5275 Handle<Object> result; | 5275 Handle<Object> result; |
5276 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5276 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
5277 isolate, result, | 5277 isolate, result, |
5278 Runtime::ForceSetObjectProperty(js_object, name, obj_value, attr)); | 5278 Runtime::ForceSetObjectProperty( |
| 5279 js_object, name, obj_value, attr, |
| 5280 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED)); |
5279 return *result; | 5281 return *result; |
5280 } | 5282 } |
5281 | 5283 |
5282 | 5284 |
5283 // Return property without being observable by accessors or interceptors. | 5285 // Return property without being observable by accessors or interceptors. |
5284 RUNTIME_FUNCTION(Runtime_GetDataProperty) { | 5286 RUNTIME_FUNCTION(Runtime_GetDataProperty) { |
5285 HandleScope scope(isolate); | 5287 HandleScope scope(isolate); |
5286 ASSERT(args.length() == 2); | 5288 ASSERT(args.length() == 2); |
5287 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5289 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
5288 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 5290 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5380 | 5382 |
5381 if (name->AsArrayIndex(&index)) { | 5383 if (name->AsArrayIndex(&index)) { |
5382 return JSObject::SetElement(js_object, index, value, attr, | 5384 return JSObject::SetElement(js_object, index, value, attr, |
5383 strict_mode, true, set_mode); | 5385 strict_mode, true, set_mode); |
5384 } else { | 5386 } else { |
5385 return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode); | 5387 return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode); |
5386 } | 5388 } |
5387 } | 5389 } |
5388 | 5390 |
5389 | 5391 |
5390 MaybeHandle<Object> Runtime::ForceSetObjectProperty(Handle<JSObject> js_object, | 5392 MaybeHandle<Object> Runtime::ForceSetObjectProperty( |
5391 Handle<Object> key, | 5393 Handle<JSObject> js_object, |
5392 Handle<Object> value, | 5394 Handle<Object> key, |
5393 PropertyAttributes attr) { | 5395 Handle<Object> value, |
| 5396 PropertyAttributes attr, |
| 5397 JSReceiver::StoreFromKeyed store_from_keyed) { |
5394 Isolate* isolate = js_object->GetIsolate(); | 5398 Isolate* isolate = js_object->GetIsolate(); |
5395 // Check if the given key is an array index. | 5399 // Check if the given key is an array index. |
5396 uint32_t index; | 5400 uint32_t index; |
5397 if (key->ToArrayIndex(&index)) { | 5401 if (key->ToArrayIndex(&index)) { |
5398 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters | 5402 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters |
5399 // of a string using [] notation. We need to support this too in | 5403 // of a string using [] notation. We need to support this too in |
5400 // JavaScript. | 5404 // JavaScript. |
5401 // In the case of a String object we just need to redirect the assignment to | 5405 // In the case of a String object we just need to redirect the assignment to |
5402 // the underlying string if the index is in range. Since the underlying | 5406 // the underlying string if the index is in range. Since the underlying |
5403 // string does nothing with the assignment then we can ignore such | 5407 // string does nothing with the assignment then we can ignore such |
5404 // assignments. | 5408 // assignments. |
5405 if (js_object->IsStringObjectWithCharacterAt(index)) { | 5409 if (js_object->IsStringObjectWithCharacterAt(index)) { |
5406 return value; | 5410 return value; |
5407 } | 5411 } |
5408 | 5412 |
5409 return JSObject::SetElement(js_object, index, value, attr, | 5413 return JSObject::SetElement(js_object, index, value, attr, |
5410 SLOPPY, false, DEFINE_PROPERTY); | 5414 SLOPPY, false, DEFINE_PROPERTY); |
5411 } | 5415 } |
5412 | 5416 |
5413 if (key->IsName()) { | 5417 if (key->IsName()) { |
5414 Handle<Name> name = Handle<Name>::cast(key); | 5418 Handle<Name> name = Handle<Name>::cast(key); |
5415 if (name->AsArrayIndex(&index)) { | 5419 if (name->AsArrayIndex(&index)) { |
5416 return JSObject::SetElement(js_object, index, value, attr, | 5420 return JSObject::SetElement(js_object, index, value, attr, |
5417 SLOPPY, false, DEFINE_PROPERTY); | 5421 SLOPPY, false, DEFINE_PROPERTY); |
5418 } else { | 5422 } else { |
5419 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name)); | 5423 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name)); |
5420 return JSObject::SetLocalPropertyIgnoreAttributes( | 5424 return JSObject::SetLocalPropertyIgnoreAttributes( |
5421 js_object, name, value, attr); | 5425 js_object, name, value, attr, Object::OPTIMAL_REPRESENTATION, |
| 5426 ALLOW_AS_CONSTANT, JSReceiver::PERFORM_EXTENSIBILITY_CHECK, |
| 5427 store_from_keyed); |
5422 } | 5428 } |
5423 } | 5429 } |
5424 | 5430 |
5425 // Call-back into JavaScript to convert the key to a string. | 5431 // Call-back into JavaScript to convert the key to a string. |
5426 Handle<Object> converted; | 5432 Handle<Object> converted; |
5427 ASSIGN_RETURN_ON_EXCEPTION( | 5433 ASSIGN_RETURN_ON_EXCEPTION( |
5428 isolate, converted, Execution::ToString(isolate, key), Object); | 5434 isolate, converted, Execution::ToString(isolate, key), Object); |
5429 Handle<String> name = Handle<String>::cast(converted); | 5435 Handle<String> name = Handle<String>::cast(converted); |
5430 | 5436 |
5431 if (name->AsArrayIndex(&index)) { | 5437 if (name->AsArrayIndex(&index)) { |
5432 return JSObject::SetElement(js_object, index, value, attr, | 5438 return JSObject::SetElement(js_object, index, value, attr, |
5433 SLOPPY, false, DEFINE_PROPERTY); | 5439 SLOPPY, false, DEFINE_PROPERTY); |
5434 } else { | 5440 } else { |
5435 return JSObject::SetLocalPropertyIgnoreAttributes(js_object, name, value, | 5441 return JSObject::SetLocalPropertyIgnoreAttributes( |
5436 attr); | 5442 js_object, name, value, attr, Object::OPTIMAL_REPRESENTATION, |
| 5443 ALLOW_AS_CONSTANT, JSReceiver::PERFORM_EXTENSIBILITY_CHECK, |
| 5444 store_from_keyed); |
5437 } | 5445 } |
5438 } | 5446 } |
5439 | 5447 |
5440 | 5448 |
5441 MaybeHandle<Object> Runtime::DeleteObjectProperty(Isolate* isolate, | 5449 MaybeHandle<Object> Runtime::DeleteObjectProperty(Isolate* isolate, |
5442 Handle<JSReceiver> receiver, | 5450 Handle<JSReceiver> receiver, |
5443 Handle<Object> key, | 5451 Handle<Object> key, |
5444 JSReceiver::DeleteMode mode) { | 5452 JSReceiver::DeleteMode mode) { |
5445 // Check if the given key is an array index. | 5453 // Check if the given key is an array index. |
5446 uint32_t index; | 5454 uint32_t index; |
(...skipping 9693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15140 } | 15148 } |
15141 return NULL; | 15149 return NULL; |
15142 } | 15150 } |
15143 | 15151 |
15144 | 15152 |
15145 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15153 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
15146 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15154 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
15147 } | 15155 } |
15148 | 15156 |
15149 } } // namespace v8::internal | 15157 } } // namespace v8::internal |
OLD | NEW |