OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 5104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5115 case INTERCEPTOR: | 5115 case INTERCEPTOR: |
5116 case TRANSITION: | 5116 case TRANSITION: |
5117 return isolate->heap()->undefined_value(); | 5117 return isolate->heap()->undefined_value(); |
5118 case NONEXISTENT: | 5118 case NONEXISTENT: |
5119 UNREACHABLE(); | 5119 UNREACHABLE(); |
5120 } | 5120 } |
5121 return isolate->heap()->undefined_value(); | 5121 return isolate->heap()->undefined_value(); |
5122 } | 5122 } |
5123 | 5123 |
5124 | 5124 |
5125 MaybeObject* Runtime::SetObjectPropertyOrFail( | 5125 Handle<Object> Runtime::SetObjectProperty(Isolate* isolate, |
5126 Isolate* isolate, | 5126 Handle<Object> object, |
5127 Handle<Object> object, | 5127 Handle<Object> key, |
5128 Handle<Object> key, | 5128 Handle<Object> value, |
5129 Handle<Object> value, | 5129 PropertyAttributes attr, |
5130 PropertyAttributes attr, | 5130 StrictModeFlag strict_mode) { |
5131 StrictModeFlag strict_mode) { | |
5132 CALL_HEAP_FUNCTION_PASS_EXCEPTION(isolate, | |
5133 SetObjectProperty(isolate, object, key, value, attr, strict_mode)); | |
5134 } | |
5135 | |
5136 | |
5137 MaybeObject* Runtime::SetObjectProperty(Isolate* isolate, | |
5138 Handle<Object> object, | |
5139 Handle<Object> key, | |
5140 Handle<Object> value, | |
5141 PropertyAttributes attr, | |
5142 StrictModeFlag strict_mode) { | |
5143 SetPropertyMode set_mode = attr == NONE ? SET_PROPERTY : DEFINE_PROPERTY; | 5131 SetPropertyMode set_mode = attr == NONE ? SET_PROPERTY : DEFINE_PROPERTY; |
5144 HandleScope scope(isolate); | |
5145 | 5132 |
5146 if (object->IsUndefined() || object->IsNull()) { | 5133 if (object->IsUndefined() || object->IsNull()) { |
5147 Handle<Object> args[2] = { key, object }; | 5134 Handle<Object> args[2] = { key, object }; |
5148 Handle<Object> error = | 5135 Handle<Object> error = |
5149 isolate->factory()->NewTypeError("non_object_property_store", | 5136 isolate->factory()->NewTypeError("non_object_property_store", |
5150 HandleVector(args, 2)); | 5137 HandleVector(args, 2)); |
5151 return isolate->Throw(*error); | 5138 isolate->Throw(*error); |
| 5139 return Handle<Object>(); |
5152 } | 5140 } |
5153 | 5141 |
5154 if (object->IsJSProxy()) { | 5142 if (object->IsJSProxy()) { |
5155 bool has_pending_exception = false; | 5143 bool has_pending_exception = false; |
5156 Handle<Object> name_object = key->IsSymbol() | 5144 Handle<Object> name_object = key->IsSymbol() |
5157 ? key : Execution::ToString(isolate, key, &has_pending_exception); | 5145 ? key : Execution::ToString(isolate, key, &has_pending_exception); |
5158 if (has_pending_exception) return Failure::Exception(); | 5146 if (has_pending_exception) return Handle<Object>(); // exception |
5159 Handle<Name> name = Handle<Name>::cast(name_object); | 5147 Handle<Name> name = Handle<Name>::cast(name_object); |
5160 Handle<Object> result = JSReceiver::SetProperty( | 5148 return JSReceiver::SetProperty(Handle<JSProxy>::cast(object), name, value, |
5161 Handle<JSProxy>::cast(object), name, value, attr, strict_mode); | 5149 attr, |
5162 RETURN_IF_EMPTY_HANDLE(isolate, result); | 5150 strict_mode); |
5163 return *result; | |
5164 } | 5151 } |
5165 | 5152 |
5166 // If the object isn't a JavaScript object, we ignore the store. | 5153 // If the object isn't a JavaScript object, we ignore the store. |
5167 if (!object->IsJSObject()) return *value; | 5154 if (!object->IsJSObject()) return value; |
5168 | 5155 |
5169 Handle<JSObject> js_object = Handle<JSObject>::cast(object); | 5156 Handle<JSObject> js_object = Handle<JSObject>::cast(object); |
5170 | 5157 |
5171 // Check if the given key is an array index. | 5158 // Check if the given key is an array index. |
5172 uint32_t index; | 5159 uint32_t index; |
5173 if (key->ToArrayIndex(&index)) { | 5160 if (key->ToArrayIndex(&index)) { |
5174 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters | 5161 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters |
5175 // of a string using [] notation. We need to support this too in | 5162 // of a string using [] notation. We need to support this too in |
5176 // JavaScript. | 5163 // JavaScript. |
5177 // In the case of a String object we just need to redirect the assignment to | 5164 // In the case of a String object we just need to redirect the assignment to |
5178 // the underlying string if the index is in range. Since the underlying | 5165 // the underlying string if the index is in range. Since the underlying |
5179 // string does nothing with the assignment then we can ignore such | 5166 // string does nothing with the assignment then we can ignore such |
5180 // assignments. | 5167 // assignments. |
5181 if (js_object->IsStringObjectWithCharacterAt(index)) { | 5168 if (js_object->IsStringObjectWithCharacterAt(index)) { |
5182 return *value; | 5169 return value; |
5183 } | 5170 } |
5184 | 5171 |
5185 js_object->ValidateElements(); | 5172 js_object->ValidateElements(); |
5186 if (js_object->HasExternalArrayElements()) { | 5173 if (js_object->HasExternalArrayElements()) { |
5187 if (!value->IsNumber() && !value->IsUndefined()) { | 5174 if (!value->IsNumber() && !value->IsUndefined()) { |
5188 bool has_exception; | 5175 bool has_exception; |
5189 Handle<Object> number = | 5176 Handle<Object> number = |
5190 Execution::ToNumber(isolate, value, &has_exception); | 5177 Execution::ToNumber(isolate, value, &has_exception); |
5191 if (has_exception) return Failure::Exception(); | 5178 if (has_exception) return Handle<Object>(); // exception |
5192 value = number; | 5179 value = number; |
5193 } | 5180 } |
5194 } | 5181 } |
5195 MaybeObject* result = js_object->SetElement( | 5182 Handle<Object> result = JSObject::SetElement(js_object, index, value, attr, |
5196 index, *value, attr, strict_mode, true, set_mode); | 5183 strict_mode, |
| 5184 true, |
| 5185 set_mode); |
5197 js_object->ValidateElements(); | 5186 js_object->ValidateElements(); |
5198 if (result->IsFailure()) return result; | 5187 return result.is_null() ? result : value; |
5199 return *value; | |
5200 } | 5188 } |
5201 | 5189 |
5202 if (key->IsName()) { | 5190 if (key->IsName()) { |
5203 Handle<Name> name = Handle<Name>::cast(key); | 5191 Handle<Name> name = Handle<Name>::cast(key); |
5204 if (name->AsArrayIndex(&index)) { | 5192 if (name->AsArrayIndex(&index)) { |
5205 if (js_object->HasExternalArrayElements()) { | 5193 if (js_object->HasExternalArrayElements()) { |
5206 if (!value->IsNumber() && !value->IsUndefined()) { | 5194 if (!value->IsNumber() && !value->IsUndefined()) { |
5207 bool has_exception; | 5195 bool has_exception; |
5208 Handle<Object> number = | 5196 Handle<Object> number = |
5209 Execution::ToNumber(isolate, value, &has_exception); | 5197 Execution::ToNumber(isolate, value, &has_exception); |
5210 if (has_exception) return Failure::Exception(); | 5198 if (has_exception) return Handle<Object>(); // exception |
5211 value = number; | 5199 value = number; |
5212 } | 5200 } |
5213 } | 5201 } |
5214 MaybeObject* result = js_object->SetElement( | 5202 return JSObject::SetElement(js_object, index, value, attr, strict_mode, |
5215 index, *value, attr, strict_mode, true, set_mode); | 5203 true, |
5216 if (result->IsFailure()) return result; | 5204 set_mode); |
5217 } else { | 5205 } else { |
5218 if (name->IsString()) Handle<String>::cast(name)->TryFlatten(); | 5206 if (name->IsString()) Handle<String>::cast(name)->TryFlatten(); |
5219 Handle<Object> result = | 5207 return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode); |
5220 JSReceiver::SetProperty(js_object, name, value, attr, strict_mode); | |
5221 RETURN_IF_EMPTY_HANDLE(isolate, result); | |
5222 } | 5208 } |
5223 return *value; | |
5224 } | 5209 } |
5225 | 5210 |
5226 // Call-back into JavaScript to convert the key to a string. | 5211 // Call-back into JavaScript to convert the key to a string. |
5227 bool has_pending_exception = false; | 5212 bool has_pending_exception = false; |
5228 Handle<Object> converted = | 5213 Handle<Object> converted = |
5229 Execution::ToString(isolate, key, &has_pending_exception); | 5214 Execution::ToString(isolate, key, &has_pending_exception); |
5230 if (has_pending_exception) return Failure::Exception(); | 5215 if (has_pending_exception) return Handle<Object>(); // exception |
5231 Handle<String> name = Handle<String>::cast(converted); | 5216 Handle<String> name = Handle<String>::cast(converted); |
5232 | 5217 |
5233 if (name->AsArrayIndex(&index)) { | 5218 if (name->AsArrayIndex(&index)) { |
5234 return js_object->SetElement( | 5219 return JSObject::SetElement(js_object, index, value, attr, strict_mode, |
5235 index, *value, attr, strict_mode, true, set_mode); | 5220 true, |
| 5221 set_mode); |
5236 } else { | 5222 } else { |
5237 Handle<Object> result = | 5223 return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode); |
5238 JSReceiver::SetProperty(js_object, name, value, attr, strict_mode); | |
5239 RETURN_IF_EMPTY_HANDLE(isolate, result); | |
5240 return *result; | |
5241 } | 5224 } |
5242 } | 5225 } |
5243 | 5226 |
5244 | 5227 |
5245 Handle<Object> Runtime::ForceSetObjectProperty(Isolate* isolate, | 5228 Handle<Object> Runtime::ForceSetObjectProperty(Isolate* isolate, |
5246 Handle<JSObject> js_object, | 5229 Handle<JSObject> js_object, |
5247 Handle<Object> key, | 5230 Handle<Object> key, |
5248 Handle<Object> value, | 5231 Handle<Object> value, |
5249 PropertyAttributes attr) { | 5232 PropertyAttributes attr) { |
5250 // Check if the given key is an array index. | 5233 // Check if the given key is an array index. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5334 } | 5317 } |
5335 | 5318 |
5336 if (name->IsString()) Handle<String>::cast(name)->TryFlatten(); | 5319 if (name->IsString()) Handle<String>::cast(name)->TryFlatten(); |
5337 Handle<Object> result = JSReceiver::DeleteProperty(receiver, name, mode); | 5320 Handle<Object> result = JSReceiver::DeleteProperty(receiver, name, mode); |
5338 RETURN_IF_EMPTY_HANDLE(isolate, result); | 5321 RETURN_IF_EMPTY_HANDLE(isolate, result); |
5339 return *result; | 5322 return *result; |
5340 } | 5323 } |
5341 | 5324 |
5342 | 5325 |
5343 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) { | 5326 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) { |
5344 SealHandleScope shs(isolate); | 5327 HandleScope scope(isolate); |
5345 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); | 5328 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); |
5346 | 5329 |
5347 Handle<Object> object = args.at<Object>(0); | 5330 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
5348 Handle<Object> key = args.at<Object>(1); | 5331 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
5349 Handle<Object> value = args.at<Object>(2); | 5332 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
5350 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); | 5333 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); |
5351 RUNTIME_ASSERT( | 5334 RUNTIME_ASSERT( |
5352 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 5335 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
5353 // Compute attributes. | 5336 // Compute attributes. |
5354 PropertyAttributes attributes = | 5337 PropertyAttributes attributes = |
5355 static_cast<PropertyAttributes>(unchecked_attributes); | 5338 static_cast<PropertyAttributes>(unchecked_attributes); |
5356 | 5339 |
5357 StrictModeFlag strict_mode = kNonStrictMode; | 5340 StrictModeFlag strict_mode = kNonStrictMode; |
5358 if (args.length() == 5) { | 5341 if (args.length() == 5) { |
5359 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_flag, 4); | 5342 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_flag, 4); |
5360 strict_mode = strict_mode_flag; | 5343 strict_mode = strict_mode_flag; |
5361 } | 5344 } |
5362 | 5345 |
5363 return Runtime::SetObjectProperty(isolate, | 5346 Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key, |
5364 object, | 5347 value, |
5365 key, | 5348 attributes, |
5366 value, | 5349 strict_mode); |
5367 attributes, | 5350 RETURN_IF_EMPTY_HANDLE(isolate, result); |
5368 strict_mode); | 5351 return *result; |
5369 } | 5352 } |
5370 | 5353 |
5371 | 5354 |
5372 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsKind) { | 5355 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsKind) { |
5373 HandleScope scope(isolate); | 5356 HandleScope scope(isolate); |
5374 RUNTIME_ASSERT(args.length() == 2); | 5357 RUNTIME_ASSERT(args.length() == 2); |
5375 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 5358 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
5376 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1); | 5359 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1); |
5377 JSObject::TransitionElementsKind(array, map->elements_kind()); | 5360 JSObject::TransitionElementsKind(array, map->elements_kind()); |
5378 return *array; | 5361 return *array; |
5379 } | 5362 } |
5380 | 5363 |
5381 | 5364 |
5382 // Set the native flag on the function. | 5365 // Set the native flag on the function. |
5383 // This is used to decide if we should transform null and undefined | 5366 // This is used to decide if we should transform null and undefined |
5384 // into the global object when doing call and apply. | 5367 // into the global object when doing call and apply. |
5385 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNativeFlag) { | 5368 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNativeFlag) { |
5386 SealHandleScope shs(isolate); | 5369 SealHandleScope shs(isolate); |
5387 RUNTIME_ASSERT(args.length() == 1); | 5370 RUNTIME_ASSERT(args.length() == 1); |
5388 | 5371 |
5389 Handle<Object> object = args.at<Object>(0); | 5372 CONVERT_ARG_CHECKED(Object, object, 0); |
5390 | 5373 |
5391 if (object->IsJSFunction()) { | 5374 if (object->IsJSFunction()) { |
5392 JSFunction* func = JSFunction::cast(*object); | 5375 JSFunction* func = JSFunction::cast(object); |
5393 func->shared()->set_native(true); | 5376 func->shared()->set_native(true); |
5394 } | 5377 } |
5395 return isolate->heap()->undefined_value(); | 5378 return isolate->heap()->undefined_value(); |
5396 } | 5379 } |
5397 | 5380 |
5398 | 5381 |
5399 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) { | 5382 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) { |
5400 HandleScope scope(isolate); | 5383 HandleScope scope(isolate); |
5401 RUNTIME_ASSERT(args.length() == 5); | 5384 RUNTIME_ASSERT(args.length() == 5); |
5402 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5385 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
(...skipping 5937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11340 // First fill all parameters. | 11323 // First fill all parameters. |
11341 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 11324 for (int i = 0; i < scope_info->ParameterCount(); ++i) { |
11342 Handle<Object> value(i < frame_inspector->GetParametersCount() | 11325 Handle<Object> value(i < frame_inspector->GetParametersCount() |
11343 ? frame_inspector->GetParameter(i) | 11326 ? frame_inspector->GetParameter(i) |
11344 : isolate->heap()->undefined_value(), | 11327 : isolate->heap()->undefined_value(), |
11345 isolate); | 11328 isolate); |
11346 ASSERT(!value->IsTheHole()); | 11329 ASSERT(!value->IsTheHole()); |
11347 | 11330 |
11348 RETURN_IF_EMPTY_HANDLE_VALUE( | 11331 RETURN_IF_EMPTY_HANDLE_VALUE( |
11349 isolate, | 11332 isolate, |
11350 SetProperty(isolate, | 11333 Runtime::SetObjectProperty(isolate, |
11351 target, | 11334 target, |
11352 Handle<String>(scope_info->ParameterName(i)), | 11335 Handle<String>(scope_info->ParameterName(i)), |
11353 value, | 11336 value, |
11354 NONE, | 11337 NONE, |
11355 kNonStrictMode), | 11338 kNonStrictMode), |
11356 Handle<JSObject>()); | 11339 Handle<JSObject>()); |
11357 } | 11340 } |
11358 | 11341 |
11359 // Second fill all stack locals. | 11342 // Second fill all stack locals. |
11360 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 11343 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
11361 Handle<Object> value(frame_inspector->GetExpression(i), isolate); | 11344 Handle<Object> value(frame_inspector->GetExpression(i), isolate); |
11362 if (value->IsTheHole()) continue; | 11345 if (value->IsTheHole()) continue; |
11363 | 11346 |
11364 RETURN_IF_EMPTY_HANDLE_VALUE( | 11347 RETURN_IF_EMPTY_HANDLE_VALUE( |
11365 isolate, | 11348 isolate, |
11366 SetProperty(isolate, | 11349 Runtime::SetObjectProperty( |
11367 target, | 11350 isolate, |
11368 Handle<String>(scope_info->StackLocalName(i)), | 11351 target, |
11369 value, | 11352 Handle<String>(scope_info->StackLocalName(i)), |
11370 NONE, | 11353 value, |
11371 kNonStrictMode), | 11354 NONE, |
| 11355 kNonStrictMode), |
11372 Handle<JSObject>()); | 11356 Handle<JSObject>()); |
11373 } | 11357 } |
11374 | 11358 |
11375 return target; | 11359 return target; |
11376 } | 11360 } |
11377 | 11361 |
11378 | 11362 |
11379 static void UpdateStackLocalsFromMaterializedObject(Isolate* isolate, | 11363 static void UpdateStackLocalsFromMaterializedObject(Isolate* isolate, |
11380 Handle<JSObject> target, | 11364 Handle<JSObject> target, |
11381 Handle<JSFunction> function, | 11365 Handle<JSFunction> function, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11439 Handle<FixedArray> keys = | 11423 Handle<FixedArray> keys = |
11440 GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw); | 11424 GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw); |
11441 if (threw) return Handle<JSObject>(); | 11425 if (threw) return Handle<JSObject>(); |
11442 | 11426 |
11443 for (int i = 0; i < keys->length(); i++) { | 11427 for (int i = 0; i < keys->length(); i++) { |
11444 // Names of variables introduced by eval are strings. | 11428 // Names of variables introduced by eval are strings. |
11445 ASSERT(keys->get(i)->IsString()); | 11429 ASSERT(keys->get(i)->IsString()); |
11446 Handle<String> key(String::cast(keys->get(i))); | 11430 Handle<String> key(String::cast(keys->get(i))); |
11447 RETURN_IF_EMPTY_HANDLE_VALUE( | 11431 RETURN_IF_EMPTY_HANDLE_VALUE( |
11448 isolate, | 11432 isolate, |
11449 SetProperty(isolate, | 11433 Runtime::SetObjectProperty(isolate, |
11450 target, | 11434 target, |
11451 key, | 11435 key, |
11452 GetProperty(isolate, ext, key), | 11436 GetProperty(isolate, ext, key), |
11453 NONE, | 11437 NONE, |
11454 kNonStrictMode), | 11438 kNonStrictMode), |
11455 Handle<JSObject>()); | 11439 Handle<JSObject>()); |
11456 } | 11440 } |
11457 } | 11441 } |
11458 } | 11442 } |
11459 | 11443 |
11460 return target; | 11444 return target; |
11461 } | 11445 } |
11462 | 11446 |
11463 | 11447 |
11464 static Handle<JSObject> MaterializeLocalScope( | 11448 static Handle<JSObject> MaterializeLocalScope( |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11544 | 11528 |
11545 // Function context extension. These are variables introduced by eval. | 11529 // Function context extension. These are variables introduced by eval. |
11546 if (function_context->closure() == *function) { | 11530 if (function_context->closure() == *function) { |
11547 if (function_context->has_extension() && | 11531 if (function_context->has_extension() && |
11548 !function_context->IsNativeContext()) { | 11532 !function_context->IsNativeContext()) { |
11549 Handle<JSObject> ext(JSObject::cast(function_context->extension())); | 11533 Handle<JSObject> ext(JSObject::cast(function_context->extension())); |
11550 | 11534 |
11551 if (JSReceiver::HasProperty(ext, variable_name)) { | 11535 if (JSReceiver::HasProperty(ext, variable_name)) { |
11552 // We don't expect this to do anything except replacing | 11536 // We don't expect this to do anything except replacing |
11553 // property value. | 11537 // property value. |
11554 SetProperty(isolate, | 11538 Runtime::SetObjectProperty(isolate, ext, variable_name, new_value, |
11555 ext, | 11539 NONE, |
11556 variable_name, | 11540 kNonStrictMode); |
11557 new_value, | |
11558 NONE, | |
11559 kNonStrictMode); | |
11560 return true; | 11541 return true; |
11561 } | 11542 } |
11562 } | 11543 } |
11563 } | 11544 } |
11564 } | 11545 } |
11565 | 11546 |
11566 return default_result; | 11547 return default_result; |
11567 } | 11548 } |
11568 | 11549 |
11569 | 11550 |
(...skipping 25 matching lines...) Expand all Loading... |
11595 Handle<FixedArray> keys = | 11576 Handle<FixedArray> keys = |
11596 GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw); | 11577 GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw); |
11597 if (threw) return Handle<JSObject>(); | 11578 if (threw) return Handle<JSObject>(); |
11598 | 11579 |
11599 for (int i = 0; i < keys->length(); i++) { | 11580 for (int i = 0; i < keys->length(); i++) { |
11600 // Names of variables introduced by eval are strings. | 11581 // Names of variables introduced by eval are strings. |
11601 ASSERT(keys->get(i)->IsString()); | 11582 ASSERT(keys->get(i)->IsString()); |
11602 Handle<String> key(String::cast(keys->get(i))); | 11583 Handle<String> key(String::cast(keys->get(i))); |
11603 RETURN_IF_EMPTY_HANDLE_VALUE( | 11584 RETURN_IF_EMPTY_HANDLE_VALUE( |
11604 isolate, | 11585 isolate, |
11605 SetProperty(isolate, | 11586 Runtime::SetObjectProperty(isolate, closure_scope, key, |
11606 closure_scope, | 11587 GetProperty(isolate, ext, key), |
11607 key, | 11588 NONE, |
11608 GetProperty(isolate, ext, key), | 11589 kNonStrictMode), |
11609 NONE, | |
11610 kNonStrictMode), | |
11611 Handle<JSObject>()); | 11590 Handle<JSObject>()); |
11612 } | 11591 } |
11613 } | 11592 } |
11614 | 11593 |
11615 return closure_scope; | 11594 return closure_scope; |
11616 } | 11595 } |
11617 | 11596 |
11618 | 11597 |
11619 // This method copies structure of MaterializeClosure method above. | 11598 // This method copies structure of MaterializeClosure method above. |
11620 static bool SetClosureVariableValue(Isolate* isolate, | 11599 static bool SetClosureVariableValue(Isolate* isolate, |
(...skipping 10 matching lines...) Expand all Loading... |
11631 isolate, scope_info, context, variable_name, new_value)) { | 11610 isolate, scope_info, context, variable_name, new_value)) { |
11632 return true; | 11611 return true; |
11633 } | 11612 } |
11634 | 11613 |
11635 // Properties from the function context extension. This will | 11614 // Properties from the function context extension. This will |
11636 // be variables introduced by eval. | 11615 // be variables introduced by eval. |
11637 if (context->has_extension()) { | 11616 if (context->has_extension()) { |
11638 Handle<JSObject> ext(JSObject::cast(context->extension())); | 11617 Handle<JSObject> ext(JSObject::cast(context->extension())); |
11639 if (JSReceiver::HasProperty(ext, variable_name)) { | 11618 if (JSReceiver::HasProperty(ext, variable_name)) { |
11640 // We don't expect this to do anything except replacing property value. | 11619 // We don't expect this to do anything except replacing property value. |
11641 SetProperty(isolate, | 11620 Runtime::SetObjectProperty(isolate, ext, variable_name, new_value, |
11642 ext, | 11621 NONE, |
11643 variable_name, | 11622 kNonStrictMode); |
11644 new_value, | |
11645 NONE, | |
11646 kNonStrictMode); | |
11647 return true; | 11623 return true; |
11648 } | 11624 } |
11649 } | 11625 } |
11650 | 11626 |
11651 return false; | 11627 return false; |
11652 } | 11628 } |
11653 | 11629 |
11654 | 11630 |
11655 // Create a plain JSObject which materializes the scope for the specified | 11631 // Create a plain JSObject which materializes the scope for the specified |
11656 // catch context. | 11632 // catch context. |
11657 static Handle<JSObject> MaterializeCatchScope(Isolate* isolate, | 11633 static Handle<JSObject> MaterializeCatchScope(Isolate* isolate, |
11658 Handle<Context> context) { | 11634 Handle<Context> context) { |
11659 ASSERT(context->IsCatchContext()); | 11635 ASSERT(context->IsCatchContext()); |
11660 Handle<String> name(String::cast(context->extension())); | 11636 Handle<String> name(String::cast(context->extension())); |
11661 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX), | 11637 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX), |
11662 isolate); | 11638 isolate); |
11663 Handle<JSObject> catch_scope = | 11639 Handle<JSObject> catch_scope = |
11664 isolate->factory()->NewJSObject(isolate->object_function()); | 11640 isolate->factory()->NewJSObject(isolate->object_function()); |
11665 RETURN_IF_EMPTY_HANDLE_VALUE( | 11641 RETURN_IF_EMPTY_HANDLE_VALUE( |
11666 isolate, | 11642 isolate, |
11667 SetProperty(isolate, | 11643 Runtime::SetObjectProperty(isolate, catch_scope, name, thrown_object, |
11668 catch_scope, | 11644 NONE, |
11669 name, | 11645 kNonStrictMode), |
11670 thrown_object, | |
11671 NONE, | |
11672 kNonStrictMode), | |
11673 Handle<JSObject>()); | 11646 Handle<JSObject>()); |
11674 return catch_scope; | 11647 return catch_scope; |
11675 } | 11648 } |
11676 | 11649 |
11677 | 11650 |
11678 static bool SetCatchVariableValue(Isolate* isolate, | 11651 static bool SetCatchVariableValue(Isolate* isolate, |
11679 Handle<Context> context, | 11652 Handle<Context> context, |
11680 Handle<String> variable_name, | 11653 Handle<String> variable_name, |
11681 Handle<Object> new_value) { | 11654 Handle<Object> new_value) { |
11682 ASSERT(context->IsCatchContext()); | 11655 ASSERT(context->IsCatchContext()); |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12680 // Skip if "arguments" is already taken. | 12653 // Skip if "arguments" is already taken. |
12681 if (!function->shared()->is_function() || | 12654 if (!function->shared()->is_function() || |
12682 JSReceiver::HasLocalProperty(target, | 12655 JSReceiver::HasLocalProperty(target, |
12683 isolate->factory()->arguments_string())) { | 12656 isolate->factory()->arguments_string())) { |
12684 return target; | 12657 return target; |
12685 } | 12658 } |
12686 | 12659 |
12687 // FunctionGetArguments can't throw an exception. | 12660 // FunctionGetArguments can't throw an exception. |
12688 Handle<JSObject> arguments = Handle<JSObject>::cast( | 12661 Handle<JSObject> arguments = Handle<JSObject>::cast( |
12689 Accessors::FunctionGetArguments(function)); | 12662 Accessors::FunctionGetArguments(function)); |
12690 SetProperty(isolate, | 12663 Runtime::SetObjectProperty(isolate, target, |
12691 target, | 12664 isolate->factory()->arguments_string(), |
12692 isolate->factory()->arguments_string(), | 12665 arguments, |
12693 arguments, | 12666 ::NONE, |
12694 ::NONE, | 12667 kNonStrictMode); |
12695 kNonStrictMode); | |
12696 return target; | 12668 return target; |
12697 } | 12669 } |
12698 | 12670 |
12699 | 12671 |
12700 // Compile and evaluate source for the given context. | 12672 // Compile and evaluate source for the given context. |
12701 static MaybeObject* DebugEvaluate(Isolate* isolate, | 12673 static MaybeObject* DebugEvaluate(Isolate* isolate, |
12702 Handle<Context> context, | 12674 Handle<Context> context, |
12703 Handle<Object> context_extension, | 12675 Handle<Object> context_extension, |
12704 Handle<Object> receiver, | 12676 Handle<Object> receiver, |
12705 Handle<String> source) { | 12677 Handle<String> source) { |
(...skipping 2130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14836 // Handle last resort GC and make sure to allow future allocations | 14808 // Handle last resort GC and make sure to allow future allocations |
14837 // to grow the heap without causing GCs (if possible). | 14809 // to grow the heap without causing GCs (if possible). |
14838 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14810 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14839 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14811 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14840 "Runtime::PerformGC"); | 14812 "Runtime::PerformGC"); |
14841 } | 14813 } |
14842 } | 14814 } |
14843 | 14815 |
14844 | 14816 |
14845 } } // namespace v8::internal | 14817 } } // namespace v8::internal |
OLD | NEW |