| 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 "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
| (...skipping 5298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5309 RUNTIME_ASSERT(args.length() == 3); | 5309 RUNTIME_ASSERT(args.length() == 3); |
| 5310 | 5310 |
| 5311 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5311 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 5312 CONVERT_ARG_HANDLE_CHECKED(String, key, 1); | 5312 CONVERT_ARG_HANDLE_CHECKED(String, key, 1); |
| 5313 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 5313 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| 5314 RUNTIME_ASSERT(key->IsUniqueName()); | 5314 RUNTIME_ASSERT(key->IsUniqueName()); |
| 5315 return *JSObject::SetHiddenProperty(object, key, value); | 5315 return *JSObject::SetHiddenProperty(object, key, value); |
| 5316 } | 5316 } |
| 5317 | 5317 |
| 5318 | 5318 |
| 5319 RUNTIME_FUNCTION(Runtime_AddProperty) { | 5319 RUNTIME_FUNCTION(Runtime_AddNamedProperty) { |
| 5320 HandleScope scope(isolate); | 5320 HandleScope scope(isolate); |
| 5321 RUNTIME_ASSERT(args.length() == 4); | 5321 RUNTIME_ASSERT(args.length() == 4); |
| 5322 | 5322 |
| 5323 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5323 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 5324 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 5324 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
| 5325 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 5325 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| 5326 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); | 5326 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); |
| 5327 RUNTIME_ASSERT( | 5327 RUNTIME_ASSERT( |
| 5328 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 5328 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
| 5329 // Compute attributes. | 5329 // Compute attributes. |
| 5330 PropertyAttributes attributes = | 5330 PropertyAttributes attributes = |
| 5331 static_cast<PropertyAttributes>(unchecked_attributes); | 5331 static_cast<PropertyAttributes>(unchecked_attributes); |
| 5332 | 5332 |
| 5333 #ifdef DEBUG | 5333 #ifdef DEBUG |
| 5334 bool duplicate; | |
| 5335 uint32_t index = 0; | 5334 uint32_t index = 0; |
| 5336 if (key->IsName() || !key->ToArrayIndex(&index)) { | 5335 ASSERT(!key->ToArrayIndex(&index)); |
| 5337 if (key->IsNumber()) { | 5336 LookupIterator it(object, key, LookupIterator::CHECK_OWN_REAL); |
| 5338 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, key, | 5337 JSReceiver::GetPropertyAttributes(&it); |
| 5339 Execution::ToString(isolate, key)); | 5338 RUNTIME_ASSERT(!it.IsFound()); |
| 5340 } | |
| 5341 LookupIterator it(object, Handle<Name>::cast(key), | |
| 5342 LookupIterator::CHECK_OWN_REAL); | |
| 5343 JSReceiver::GetPropertyAttributes(&it); | |
| 5344 duplicate = it.IsFound(); | |
| 5345 } else { | |
| 5346 duplicate = JSReceiver::HasOwnElement(object, index); | |
| 5347 } | |
| 5348 RUNTIME_ASSERT(!duplicate); | |
| 5349 #endif | 5339 #endif |
| 5350 | 5340 |
| 5351 Handle<Object> result; | 5341 Handle<Object> result; |
| 5352 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5342 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 5353 isolate, result, | 5343 isolate, result, |
| 5354 Runtime::DefineObjectProperty(object, key, value, attributes)); | 5344 JSObject::SetOwnPropertyIgnoreAttributes(object, key, value, attributes)); |
| 5355 return *result; | 5345 return *result; |
| 5356 } | 5346 } |
| 5357 | 5347 |
| 5358 | 5348 |
| 5359 RUNTIME_FUNCTION(Runtime_AddPropertyForTemplate) { | 5349 RUNTIME_FUNCTION(Runtime_AddPropertyForTemplate) { |
| 5360 HandleScope scope(isolate); | 5350 HandleScope scope(isolate); |
| 5361 RUNTIME_ASSERT(args.length() == 4); | 5351 RUNTIME_ASSERT(args.length() == 4); |
| 5362 | 5352 |
| 5363 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5353 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 5364 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 5354 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| (...skipping 9751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15116 } | 15106 } |
| 15117 return NULL; | 15107 return NULL; |
| 15118 } | 15108 } |
| 15119 | 15109 |
| 15120 | 15110 |
| 15121 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15111 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
| 15122 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15112 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
| 15123 } | 15113 } |
| 15124 | 15114 |
| 15125 } } // namespace v8::internal | 15115 } } // namespace v8::internal |
| OLD | NEW |