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

Side by Side Diff: src/runtime.cc

Issue 351853005: Split SetProperty(...attributes, strictmode) into AddProperty(...attributes) and SetProperty(...… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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
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 2087 matching lines...) Expand 10 before | Expand all | Expand 10 after
2098 // Transform getter or setter into something DefineAccessor can handle. 2098 // Transform getter or setter into something DefineAccessor can handle.
2099 static Handle<Object> InstantiateAccessorComponent(Isolate* isolate, 2099 static Handle<Object> InstantiateAccessorComponent(Isolate* isolate,
2100 Handle<Object> component) { 2100 Handle<Object> component) {
2101 if (component->IsUndefined()) return isolate->factory()->null_value(); 2101 if (component->IsUndefined()) return isolate->factory()->null_value();
2102 Handle<FunctionTemplateInfo> info = 2102 Handle<FunctionTemplateInfo> info =
2103 Handle<FunctionTemplateInfo>::cast(component); 2103 Handle<FunctionTemplateInfo>::cast(component);
2104 return Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction()); 2104 return Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction());
2105 } 2105 }
2106 2106
2107 2107
2108 RUNTIME_FUNCTION(Runtime_SetAccessorProperty) { 2108 RUNTIME_FUNCTION(Runtime_DefineAccessorProperty) {
2109 HandleScope scope(isolate); 2109 HandleScope scope(isolate);
2110 ASSERT(args.length() == 5); 2110 ASSERT(args.length() == 5);
2111 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 2111 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
2112 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); 2112 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
2113 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); 2113 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2);
2114 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); 2114 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3);
2115 CONVERT_SMI_ARG_CHECKED(attribute, 4); 2115 CONVERT_SMI_ARG_CHECKED(attribute, 4);
2116 RUNTIME_ASSERT(getter->IsUndefined() || getter->IsFunctionTemplateInfo()); 2116 RUNTIME_ASSERT(getter->IsUndefined() || getter->IsFunctionTemplateInfo());
2117 RUNTIME_ASSERT(setter->IsUndefined() || setter->IsFunctionTemplateInfo()); 2117 RUNTIME_ASSERT(setter->IsUndefined() || setter->IsFunctionTemplateInfo());
2118 RUNTIME_ASSERT(PropertyDetails::AttributesField::is_valid( 2118 RUNTIME_ASSERT(PropertyDetails::AttributesField::is_valid(
(...skipping 3019 matching lines...) Expand 10 before | Expand all | Expand 10 after
5138 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 5138 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
5139 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); 5139 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
5140 return *JSObject::GetDataProperty(object, key); 5140 return *JSObject::GetDataProperty(object, key);
5141 } 5141 }
5142 5142
5143 5143
5144 MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, 5144 MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate,
5145 Handle<Object> object, 5145 Handle<Object> object,
5146 Handle<Object> key, 5146 Handle<Object> key,
5147 Handle<Object> value, 5147 Handle<Object> value,
5148 PropertyAttributes attr, 5148 StrictMode strict_mode,
5149 StrictMode strict_mode) { 5149 PropertyAttributes attrs) {
5150 SetPropertyMode set_mode = attr == NONE ? SET_PROPERTY : DEFINE_PROPERTY;
5151
5152 if (object->IsUndefined() || object->IsNull()) { 5150 if (object->IsUndefined() || object->IsNull()) {
5153 Handle<Object> args[2] = { key, object }; 5151 Handle<Object> args[2] = { key, object };
5154 Handle<Object> error = 5152 Handle<Object> error =
5155 isolate->factory()->NewTypeError("non_object_property_store", 5153 isolate->factory()->NewTypeError("non_object_property_store",
5156 HandleVector(args, 2)); 5154 HandleVector(args, 2));
5157 return isolate->Throw<Object>(error); 5155 return isolate->Throw<Object>(error);
5158 } 5156 }
5159 5157
5160 if (object->IsJSProxy()) { 5158 if (object->IsJSProxy()) {
5161 Handle<Object> name_object; 5159 Handle<Object> name_object;
5162 if (key->IsSymbol()) { 5160 if (key->IsSymbol()) {
5163 name_object = key; 5161 name_object = key;
5164 } else { 5162 } else {
5165 ASSIGN_RETURN_ON_EXCEPTION( 5163 ASSIGN_RETURN_ON_EXCEPTION(
5166 isolate, name_object, Execution::ToString(isolate, key), Object); 5164 isolate, name_object, Execution::ToString(isolate, key), Object);
5167 } 5165 }
5168 Handle<Name> name = Handle<Name>::cast(name_object); 5166 Handle<Name> name = Handle<Name>::cast(name_object);
5169 return JSReceiver::SetProperty(Handle<JSProxy>::cast(object), name, value, 5167 return JSReceiver::SetProperty(Handle<JSProxy>::cast(object), name, value,
5170 attr, 5168 attrs, strict_mode);
5171 strict_mode);
5172 } 5169 }
5173 5170
5174 // If the object isn't a JavaScript object, we ignore the store. 5171 // If the object isn't a JavaScript object, we ignore the store.
5175 if (!object->IsJSObject()) return value; 5172 if (!object->IsJSObject()) return value;
5176 5173
5177 Handle<JSObject> js_object = Handle<JSObject>::cast(object); 5174 Handle<JSObject> js_object = Handle<JSObject>::cast(object);
5178 5175
5179 // Check if the given key is an array index. 5176 // Check if the given key is an array index.
5180 uint32_t index; 5177 uint32_t index;
5181 if (key->ToArrayIndex(&index)) { 5178 if (key->ToArrayIndex(&index)) {
(...skipping 11 matching lines...) Expand all
5193 JSObject::ValidateElements(js_object); 5190 JSObject::ValidateElements(js_object);
5194 if (js_object->HasExternalArrayElements() || 5191 if (js_object->HasExternalArrayElements() ||
5195 js_object->HasFixedTypedArrayElements()) { 5192 js_object->HasFixedTypedArrayElements()) {
5196 if (!value->IsNumber() && !value->IsUndefined()) { 5193 if (!value->IsNumber() && !value->IsUndefined()) {
5197 ASSIGN_RETURN_ON_EXCEPTION( 5194 ASSIGN_RETURN_ON_EXCEPTION(
5198 isolate, value, Execution::ToNumber(isolate, value), Object); 5195 isolate, value, Execution::ToNumber(isolate, value), Object);
5199 } 5196 }
5200 } 5197 }
5201 5198
5202 MaybeHandle<Object> result = JSObject::SetElement( 5199 MaybeHandle<Object> result = JSObject::SetElement(
5203 js_object, index, value, attr, strict_mode, true, set_mode); 5200 js_object, index, value, attrs, strict_mode, true, SET_PROPERTY);
5204 JSObject::ValidateElements(js_object); 5201 JSObject::ValidateElements(js_object);
5205 5202
5206 return result.is_null() ? result : value; 5203 return result.is_null() ? result : value;
5207 } 5204 }
5208 5205
5209 if (key->IsName()) { 5206 if (key->IsName()) {
5210 Handle<Name> name = Handle<Name>::cast(key); 5207 Handle<Name> name = Handle<Name>::cast(key);
5211 if (name->AsArrayIndex(&index)) { 5208 if (name->AsArrayIndex(&index)) {
5212 if (js_object->HasExternalArrayElements()) { 5209 if (js_object->HasExternalArrayElements()) {
5213 if (!value->IsNumber() && !value->IsUndefined()) { 5210 if (!value->IsNumber() && !value->IsUndefined()) {
5214 ASSIGN_RETURN_ON_EXCEPTION( 5211 ASSIGN_RETURN_ON_EXCEPTION(
5215 isolate, value, Execution::ToNumber(isolate, value), Object); 5212 isolate, value, Execution::ToNumber(isolate, value), Object);
5216 } 5213 }
5217 } 5214 }
5218 return JSObject::SetElement(js_object, index, value, attr, 5215 return JSObject::SetElement(js_object, index, value, attrs,
5219 strict_mode, true, set_mode); 5216 strict_mode, true, SET_PROPERTY);
5220 } else { 5217 } else {
5221 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name)); 5218 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name));
5222 return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode); 5219 return JSReceiver::SetProperty(
5220 js_object, name, value, attrs, strict_mode);
5223 } 5221 }
5224 } 5222 }
5225 5223
5226 // Call-back into JavaScript to convert the key to a string. 5224 // Call-back into JavaScript to convert the key to a string.
5227 Handle<Object> converted; 5225 Handle<Object> converted;
5228 ASSIGN_RETURN_ON_EXCEPTION( 5226 ASSIGN_RETURN_ON_EXCEPTION(
5229 isolate, converted, Execution::ToString(isolate, key), Object); 5227 isolate, converted, Execution::ToString(isolate, key), Object);
5230 Handle<String> name = Handle<String>::cast(converted); 5228 Handle<String> name = Handle<String>::cast(converted);
5231 5229
5232 if (name->AsArrayIndex(&index)) { 5230 if (name->AsArrayIndex(&index)) {
5233 return JSObject::SetElement(js_object, index, value, attr, 5231 return JSObject::SetElement(js_object, index, value, attrs,
5234 strict_mode, true, set_mode); 5232 strict_mode, true, SET_PROPERTY);
5235 } else { 5233 } else {
5236 return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode); 5234 return JSReceiver::SetProperty(js_object, name, value, attrs, strict_mode);
5237 } 5235 }
5238 } 5236 }
5239 5237
5240 5238
5241 MaybeHandle<Object> Runtime::ForceSetObjectProperty( 5239 MaybeHandle<Object> Runtime::ForceSetObjectProperty(
5242 Handle<JSObject> js_object, 5240 Handle<JSObject> js_object,
5243 Handle<Object> key, 5241 Handle<Object> key,
5244 Handle<Object> value, 5242 Handle<Object> value,
5245 PropertyAttributes attr, 5243 PropertyAttributes attr,
5246 JSReceiver::StoreFromKeyed store_from_keyed) { 5244 JSReceiver::StoreFromKeyed store_from_keyed) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
5336 RUNTIME_ASSERT(args.length() == 3); 5334 RUNTIME_ASSERT(args.length() == 3);
5337 5335
5338 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 5336 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
5339 CONVERT_ARG_HANDLE_CHECKED(String, key, 1); 5337 CONVERT_ARG_HANDLE_CHECKED(String, key, 1);
5340 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 5338 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
5341 RUNTIME_ASSERT(key->IsUniqueName()); 5339 RUNTIME_ASSERT(key->IsUniqueName());
5342 return *JSObject::SetHiddenProperty(object, key, value); 5340 return *JSObject::SetHiddenProperty(object, key, value);
5343 } 5341 }
5344 5342
5345 5343
5346 RUNTIME_FUNCTION(Runtime_SetProperty) { 5344 RUNTIME_FUNCTION(Runtime_DefineProperty) {
5347 HandleScope scope(isolate); 5345 HandleScope scope(isolate);
5348 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); 5346 RUNTIME_ASSERT(args.length() == 4);
5349 5347
5350 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); 5348 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
5351 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 5349 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
5352 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 5350 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
5353 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); 5351 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3);
5354 RUNTIME_ASSERT( 5352 RUNTIME_ASSERT(
5355 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); 5353 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
5356 // Compute attributes. 5354 // Compute attributes.
5357 PropertyAttributes attributes = 5355 PropertyAttributes attributes =
5358 static_cast<PropertyAttributes>(unchecked_attributes); 5356 static_cast<PropertyAttributes>(unchecked_attributes);
5359 5357
5360 StrictMode strict_mode = SLOPPY; 5358 #ifdef DEBUG
5361 if (args.length() == 5) { 5359 if (key->IsName()) {
rossberg 2014/06/27 09:47:30 Hm, it's unfortunate that one can bypass this chec
5362 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_arg, 4); 5360 LookupIterator it(object, Handle<Name>::cast(key),
5363 strict_mode = strict_mode_arg; 5361 LookupIterator::CHECK_OWN);
5362 JSReceiver::GetPropertyAttributes(&it);
5363 RUNTIME_ASSERT(!it.IsFound());
5364 } 5364 }
5365 #endif
5365 5366
5366 Handle<Object> result; 5367 Handle<Object> result;
5367 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 5368 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
5368 isolate, result, 5369 isolate, result,
5369 Runtime::SetObjectProperty( 5370 Runtime::ForceSetObjectProperty(object, key, value, attributes));
5370 isolate, object, key, value, attributes, strict_mode));
5371 return *result; 5371 return *result;
5372 } 5372 }
5373 5373
5374
5375 RUNTIME_FUNCTION(Runtime_SetProperty) {
5376 HandleScope scope(isolate);
5377 RUNTIME_ASSERT(args.length() == 4);
5378
5379 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
5380 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
5381 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
5382 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_arg, 3);
5383 StrictMode strict_mode = strict_mode_arg;
5384
5385 Handle<Object> result;
5386 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
5387 isolate, result,
5388 Runtime::SetObjectProperty(isolate, object, key, value, strict_mode));
5389 return *result;
5390 }
5391
5374 5392
5375 RUNTIME_FUNCTION(Runtime_TransitionElementsKind) { 5393 RUNTIME_FUNCTION(Runtime_TransitionElementsKind) {
5376 HandleScope scope(isolate); 5394 HandleScope scope(isolate);
5377 RUNTIME_ASSERT(args.length() == 2); 5395 RUNTIME_ASSERT(args.length() == 2);
5378 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); 5396 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0);
5379 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1); 5397 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1);
5380 JSObject::TransitionElementsKind(array, map->elements_kind()); 5398 JSObject::TransitionElementsKind(array, map->elements_kind());
5381 return *array; 5399 return *array;
5382 } 5400 }
5383 5401
(...skipping 6013 matching lines...) Expand 10 before | Expand all | Expand 10 after
11397 11415
11398 HandleScope scope(isolate); 11416 HandleScope scope(isolate);
11399 Handle<Object> value(i < frame_inspector->GetParametersCount() 11417 Handle<Object> value(i < frame_inspector->GetParametersCount()
11400 ? frame_inspector->GetParameter(i) 11418 ? frame_inspector->GetParameter(i)
11401 : isolate->heap()->undefined_value(), 11419 : isolate->heap()->undefined_value(),
11402 isolate); 11420 isolate);
11403 ASSERT(!value->IsTheHole()); 11421 ASSERT(!value->IsTheHole());
11404 11422
11405 RETURN_ON_EXCEPTION( 11423 RETURN_ON_EXCEPTION(
11406 isolate, 11424 isolate,
11407 Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY), 11425 Runtime::SetObjectProperty(isolate, target, name, value, SLOPPY),
11408 JSObject); 11426 JSObject);
11409 } 11427 }
11410 11428
11411 // Second fill all stack locals. 11429 // Second fill all stack locals.
11412 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { 11430 for (int i = 0; i < scope_info->StackLocalCount(); ++i) {
11413 if (scope_info->LocalIsSynthetic(i)) continue; 11431 if (scope_info->LocalIsSynthetic(i)) continue;
11414 Handle<String> name(scope_info->StackLocalName(i)); 11432 Handle<String> name(scope_info->StackLocalName(i));
11415 Handle<Object> value(frame_inspector->GetExpression(i), isolate); 11433 Handle<Object> value(frame_inspector->GetExpression(i), isolate);
11416 if (value->IsTheHole()) continue; 11434 if (value->IsTheHole()) continue;
11417 11435
11418 RETURN_ON_EXCEPTION( 11436 RETURN_ON_EXCEPTION(
11419 isolate, 11437 isolate,
11420 Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY), 11438 Runtime::SetObjectProperty(isolate, target, name, value, SLOPPY),
11421 JSObject); 11439 JSObject);
11422 } 11440 }
11423 11441
11424 return target; 11442 return target;
11425 } 11443 }
11426 11444
11427 11445
11428 static void UpdateStackLocalsFromMaterializedObject(Isolate* isolate, 11446 static void UpdateStackLocalsFromMaterializedObject(Isolate* isolate,
11429 Handle<JSObject> target, 11447 Handle<JSObject> target,
11430 Handle<JSFunction> function, 11448 Handle<JSFunction> function,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
11499 11517
11500 for (int i = 0; i < keys->length(); i++) { 11518 for (int i = 0; i < keys->length(); i++) {
11501 // Names of variables introduced by eval are strings. 11519 // Names of variables introduced by eval are strings.
11502 ASSERT(keys->get(i)->IsString()); 11520 ASSERT(keys->get(i)->IsString());
11503 Handle<String> key(String::cast(keys->get(i))); 11521 Handle<String> key(String::cast(keys->get(i)));
11504 Handle<Object> value; 11522 Handle<Object> value;
11505 ASSIGN_RETURN_ON_EXCEPTION( 11523 ASSIGN_RETURN_ON_EXCEPTION(
11506 isolate, value, Object::GetPropertyOrElement(ext, key), JSObject); 11524 isolate, value, Object::GetPropertyOrElement(ext, key), JSObject);
11507 RETURN_ON_EXCEPTION( 11525 RETURN_ON_EXCEPTION(
11508 isolate, 11526 isolate,
11509 Runtime::SetObjectProperty( 11527 Runtime::SetObjectProperty(isolate, target, key, value, SLOPPY),
11510 isolate, target, key, value, NONE, SLOPPY),
11511 JSObject); 11528 JSObject);
11512 } 11529 }
11513 } 11530 }
11514 } 11531 }
11515 11532
11516 return target; 11533 return target;
11517 } 11534 }
11518 11535
11519 11536
11520 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalScope( 11537 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalScope(
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
11605 // Function context extension. These are variables introduced by eval. 11622 // Function context extension. These are variables introduced by eval.
11606 if (function_context->closure() == *function) { 11623 if (function_context->closure() == *function) {
11607 if (function_context->has_extension() && 11624 if (function_context->has_extension() &&
11608 !function_context->IsNativeContext()) { 11625 !function_context->IsNativeContext()) {
11609 Handle<JSObject> ext(JSObject::cast(function_context->extension())); 11626 Handle<JSObject> ext(JSObject::cast(function_context->extension()));
11610 11627
11611 if (JSReceiver::HasProperty(ext, variable_name)) { 11628 if (JSReceiver::HasProperty(ext, variable_name)) {
11612 // We don't expect this to do anything except replacing 11629 // We don't expect this to do anything except replacing
11613 // property value. 11630 // property value.
11614 Runtime::SetObjectProperty(isolate, ext, variable_name, new_value, 11631 Runtime::SetObjectProperty(isolate, ext, variable_name, new_value,
11615 NONE, SLOPPY).Assert(); 11632 SLOPPY).Assert();
11616 return true; 11633 return true;
11617 } 11634 }
11618 } 11635 }
11619 } 11636 }
11620 } 11637 }
11621 11638
11622 return default_result; 11639 return default_result;
11623 } 11640 }
11624 11641
11625 11642
(...skipping 30 matching lines...) Expand all
11656 for (int i = 0; i < keys->length(); i++) { 11673 for (int i = 0; i < keys->length(); i++) {
11657 HandleScope scope(isolate); 11674 HandleScope scope(isolate);
11658 // Names of variables introduced by eval are strings. 11675 // Names of variables introduced by eval are strings.
11659 ASSERT(keys->get(i)->IsString()); 11676 ASSERT(keys->get(i)->IsString());
11660 Handle<String> key(String::cast(keys->get(i))); 11677 Handle<String> key(String::cast(keys->get(i)));
11661 Handle<Object> value; 11678 Handle<Object> value;
11662 ASSIGN_RETURN_ON_EXCEPTION( 11679 ASSIGN_RETURN_ON_EXCEPTION(
11663 isolate, value, Object::GetPropertyOrElement(ext, key), JSObject); 11680 isolate, value, Object::GetPropertyOrElement(ext, key), JSObject);
11664 RETURN_ON_EXCEPTION( 11681 RETURN_ON_EXCEPTION(
11665 isolate, 11682 isolate,
11666 Runtime::SetObjectProperty( 11683 Runtime::ForceSetObjectProperty(closure_scope, key, value, NONE),
11667 isolate, closure_scope, key, value, NONE, SLOPPY),
11668 JSObject); 11684 JSObject);
11669 } 11685 }
11670 } 11686 }
11671 11687
11672 return closure_scope; 11688 return closure_scope;
11673 } 11689 }
11674 11690
11675 11691
11676 // This method copies structure of MaterializeClosure method above. 11692 // This method copies structure of MaterializeClosure method above.
11677 static bool SetClosureVariableValue(Isolate* isolate, 11693 static bool SetClosureVariableValue(Isolate* isolate,
(...skipping 10 matching lines...) Expand all
11688 isolate, scope_info, context, variable_name, new_value)) { 11704 isolate, scope_info, context, variable_name, new_value)) {
11689 return true; 11705 return true;
11690 } 11706 }
11691 11707
11692 // Properties from the function context extension. This will 11708 // Properties from the function context extension. This will
11693 // be variables introduced by eval. 11709 // be variables introduced by eval.
11694 if (context->has_extension()) { 11710 if (context->has_extension()) {
11695 Handle<JSObject> ext(JSObject::cast(context->extension())); 11711 Handle<JSObject> ext(JSObject::cast(context->extension()));
11696 if (JSReceiver::HasProperty(ext, variable_name)) { 11712 if (JSReceiver::HasProperty(ext, variable_name)) {
11697 // We don't expect this to do anything except replacing property value. 11713 // We don't expect this to do anything except replacing property value.
11698 Runtime::SetObjectProperty(isolate, ext, variable_name, new_value, 11714 Runtime::ForceSetObjectProperty(
11699 NONE, SLOPPY).Assert(); 11715 ext, variable_name, new_value, NONE).Assert();
11700 return true; 11716 return true;
11701 } 11717 }
11702 } 11718 }
11703 11719
11704 return false; 11720 return false;
11705 } 11721 }
11706 11722
11707 11723
11708 // Create a plain JSObject which materializes the scope for the specified 11724 // Create a plain JSObject which materializes the scope for the specified
11709 // catch context. 11725 // catch context.
11710 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeCatchScope( 11726 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeCatchScope(
11711 Isolate* isolate, 11727 Isolate* isolate,
11712 Handle<Context> context) { 11728 Handle<Context> context) {
11713 ASSERT(context->IsCatchContext()); 11729 ASSERT(context->IsCatchContext());
11714 Handle<String> name(String::cast(context->extension())); 11730 Handle<String> name(String::cast(context->extension()));
11715 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX), 11731 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX),
11716 isolate); 11732 isolate);
11717 Handle<JSObject> catch_scope = 11733 Handle<JSObject> catch_scope =
11718 isolate->factory()->NewJSObject(isolate->object_function()); 11734 isolate->factory()->NewJSObject(isolate->object_function());
11719 RETURN_ON_EXCEPTION( 11735 RETURN_ON_EXCEPTION(
11720 isolate, 11736 isolate,
11721 Runtime::SetObjectProperty(isolate, catch_scope, name, thrown_object, 11737 Runtime::ForceSetObjectProperty(catch_scope, name, thrown_object, NONE),
11722 NONE, SLOPPY),
11723 JSObject); 11738 JSObject);
11724 return catch_scope; 11739 return catch_scope;
11725 } 11740 }
11726 11741
11727 11742
11728 static bool SetCatchVariableValue(Isolate* isolate, 11743 static bool SetCatchVariableValue(Isolate* isolate,
11729 Handle<Context> context, 11744 Handle<Context> context,
11730 Handle<String> variable_name, 11745 Handle<String> variable_name,
11731 Handle<Object> new_value) { 11746 Handle<Object> new_value) {
11732 ASSERT(context->IsCatchContext()); 11747 ASSERT(context->IsCatchContext());
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
12775 target, isolate->factory()->arguments_string())) { 12790 target, isolate->factory()->arguments_string())) {
12776 return target; 12791 return target;
12777 } 12792 }
12778 12793
12779 // FunctionGetArguments can't throw an exception. 12794 // FunctionGetArguments can't throw an exception.
12780 Handle<JSObject> arguments = Handle<JSObject>::cast( 12795 Handle<JSObject> arguments = Handle<JSObject>::cast(
12781 Accessors::FunctionGetArguments(function)); 12796 Accessors::FunctionGetArguments(function));
12782 Handle<String> arguments_str = isolate->factory()->arguments_string(); 12797 Handle<String> arguments_str = isolate->factory()->arguments_string();
12783 RETURN_ON_EXCEPTION( 12798 RETURN_ON_EXCEPTION(
12784 isolate, 12799 isolate,
12785 Runtime::SetObjectProperty( 12800 Runtime::ForceSetObjectProperty(target, arguments_str, arguments, NONE),
12786 isolate, target, arguments_str, arguments, ::NONE, SLOPPY),
12787 JSObject); 12801 JSObject);
12788 return target; 12802 return target;
12789 } 12803 }
12790 12804
12791 12805
12792 // Compile and evaluate source for the given context. 12806 // Compile and evaluate source for the given context.
12793 static MaybeHandle<Object> DebugEvaluate(Isolate* isolate, 12807 static MaybeHandle<Object> DebugEvaluate(Isolate* isolate,
12794 Handle<Context> context, 12808 Handle<Context> context,
12795 Handle<Object> context_extension, 12809 Handle<Object> context_extension,
12796 Handle<Object> receiver, 12810 Handle<Object> receiver,
(...skipping 2312 matching lines...) Expand 10 before | Expand all | Expand 10 after
15109 } 15123 }
15110 return NULL; 15124 return NULL;
15111 } 15125 }
15112 15126
15113 15127
15114 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15128 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15115 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15129 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15116 } 15130 }
15117 15131
15118 } } // namespace v8::internal 15132 } } // namespace v8::internal
OLDNEW
« src/runtime.h ('K') | « src/runtime.h ('k') | src/scopeinfo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698