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

Side by Side Diff: src/runtime.cc

Issue 24205004: Rollback trunk to 3.21.16.2 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 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') | src/stub-cache.h » ('j') | 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 // 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 if (*boilerplate == isolate->heap()->undefined_value()) { 492 if (*boilerplate == isolate->heap()->undefined_value()) {
493 boilerplate = CreateObjectLiteralBoilerplate(isolate, 493 boilerplate = CreateObjectLiteralBoilerplate(isolate,
494 literals, 494 literals,
495 constant_properties, 495 constant_properties,
496 should_have_fast_elements, 496 should_have_fast_elements,
497 has_function_literal); 497 has_function_literal);
498 RETURN_IF_EMPTY_HANDLE(isolate, boilerplate); 498 RETURN_IF_EMPTY_HANDLE(isolate, boilerplate);
499 // Update the functions literal and return the boilerplate. 499 // Update the functions literal and return the boilerplate.
500 literals->set(literals_index, *boilerplate); 500 literals->set(literals_index, *boilerplate);
501 } 501 }
502 502 return JSObject::cast(*boilerplate)->DeepCopy(isolate);
503 Handle<Object> copy = JSObject::DeepCopy(Handle<JSObject>::cast(boilerplate));
504 RETURN_IF_EMPTY_HANDLE(isolate, copy);
505 return *copy;
506 } 503 }
507 504
508 505
509 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteralShallow) { 506 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteralShallow) {
510 HandleScope scope(isolate); 507 HandleScope scope(isolate);
511 ASSERT(args.length() == 4); 508 ASSERT(args.length() == 4);
512 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); 509 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
513 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 510 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
514 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); 511 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2);
515 CONVERT_SMI_ARG_CHECKED(flags, 3); 512 CONVERT_SMI_ARG_CHECKED(flags, 3);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 HandleScope scope(isolate); 557 HandleScope scope(isolate);
561 ASSERT(args.length() == 3); 558 ASSERT(args.length() == 3);
562 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); 559 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
563 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 560 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
564 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); 561 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
565 562
566 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals, 563 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals,
567 literals_index, elements); 564 literals_index, elements);
568 RETURN_IF_EMPTY_HANDLE(isolate, site); 565 RETURN_IF_EMPTY_HANDLE(isolate, site);
569 566
570 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info())); 567 JSObject* boilerplate = JSObject::cast(site->transition_info());
571 Handle<JSObject> copy = JSObject::DeepCopy(boilerplate); 568 return boilerplate->DeepCopy(isolate);
572 RETURN_IF_EMPTY_HANDLE(isolate, copy);
573 return *copy;
574 } 569 }
575 570
576 571
577 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) { 572 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) {
578 HandleScope scope(isolate); 573 HandleScope scope(isolate);
579 ASSERT(args.length() == 3); 574 ASSERT(args.length() == 3);
580 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); 575 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
581 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 576 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
582 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); 577 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
583 578
(...skipping 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after
2162 ASSERT(context->IsFunctionContext()); 2157 ASSERT(context->IsFunctionContext());
2163 object = isolate->factory()->NewJSObject( 2158 object = isolate->factory()->NewJSObject(
2164 isolate->context_extension_function()); 2159 isolate->context_extension_function());
2165 context->set_extension(*object); 2160 context->set_extension(*object);
2166 } 2161 }
2167 ASSERT(*object != NULL); 2162 ASSERT(*object != NULL);
2168 2163
2169 // Declare the property by setting it to the initial value if provided, 2164 // Declare the property by setting it to the initial value if provided,
2170 // or undefined, and use the correct mode (e.g. READ_ONLY attribute for 2165 // or undefined, and use the correct mode (e.g. READ_ONLY attribute for
2171 // constant declarations). 2166 // constant declarations).
2172 ASSERT(!JSReceiver::HasLocalProperty(object, name)); 2167 ASSERT(!object->HasLocalProperty(*name));
2173 Handle<Object> value(isolate->heap()->undefined_value(), isolate); 2168 Handle<Object> value(isolate->heap()->undefined_value(), isolate);
2174 if (*initial_value != NULL) value = initial_value; 2169 if (*initial_value != NULL) value = initial_value;
2175 // Declaring a const context slot is a conflicting declaration if 2170 // Declaring a const context slot is a conflicting declaration if
2176 // there is a callback with that name in a prototype. It is 2171 // there is a callback with that name in a prototype. It is
2177 // allowed to introduce const variables in 2172 // allowed to introduce const variables in
2178 // JSContextExtensionObjects. They are treated specially in 2173 // JSContextExtensionObjects. They are treated specially in
2179 // SetProperty and no setters are invoked for those since they are 2174 // SetProperty and no setters are invoked for those since they are
2180 // not real JSObjects. 2175 // not real JSObjects.
2181 if (initial_value->IsTheHole() && 2176 if (initial_value->IsTheHole() &&
2182 !object->IsJSContextExtensionObject()) { 2177 !object->IsJSContextExtensionObject()) {
(...skipping 11 matching lines...) Expand all
2194 RETURN_IF_EMPTY_HANDLE(isolate, 2189 RETURN_IF_EMPTY_HANDLE(isolate,
2195 JSReceiver::SetProperty(object, name, value, mode, kNonStrictMode)); 2190 JSReceiver::SetProperty(object, name, value, mode, kNonStrictMode));
2196 } 2191 }
2197 } 2192 }
2198 2193
2199 return isolate->heap()->undefined_value(); 2194 return isolate->heap()->undefined_value();
2200 } 2195 }
2201 2196
2202 2197
2203 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { 2198 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) {
2204 HandleScope scope(isolate); 2199 SealHandleScope shs(isolate);
2205 // args[0] == name 2200 // args[0] == name
2206 // args[1] == language_mode 2201 // args[1] == language_mode
2207 // args[2] == value (optional) 2202 // args[2] == value (optional)
2208 2203
2209 // Determine if we need to assign to the variable if it already 2204 // Determine if we need to assign to the variable if it already
2210 // exists (based on the number of arguments). 2205 // exists (based on the number of arguments).
2211 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); 2206 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3);
2212 bool assign = args.length() == 3; 2207 bool assign = args.length() == 3;
2213 2208
2214 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); 2209 CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
2210 GlobalObject* global = isolate->context()->global_object();
2215 RUNTIME_ASSERT(args[1]->IsSmi()); 2211 RUNTIME_ASSERT(args[1]->IsSmi());
2216 CONVERT_LANGUAGE_MODE_ARG(language_mode, 1); 2212 CONVERT_LANGUAGE_MODE_ARG(language_mode, 1);
2217 StrictModeFlag strict_mode_flag = (language_mode == CLASSIC_MODE) 2213 StrictModeFlag strict_mode_flag = (language_mode == CLASSIC_MODE)
2218 ? kNonStrictMode : kStrictMode; 2214 ? kNonStrictMode : kStrictMode;
2219 2215
2220 // According to ECMA-262, section 12.2, page 62, the property must 2216 // According to ECMA-262, section 12.2, page 62, the property must
2221 // not be deletable. 2217 // not be deletable.
2222 PropertyAttributes attributes = DONT_DELETE; 2218 PropertyAttributes attributes = DONT_DELETE;
2223 2219
2224 // Lookup the property locally in the global object. If it isn't 2220 // Lookup the property locally in the global object. If it isn't
2225 // there, there is a property with this name in the prototype chain. 2221 // there, there is a property with this name in the prototype chain.
2226 // We follow Safari and Firefox behavior and only set the property 2222 // We follow Safari and Firefox behavior and only set the property
2227 // locally if there is an explicit initialization value that we have 2223 // locally if there is an explicit initialization value that we have
2228 // to assign to the property. 2224 // to assign to the property.
2229 // Note that objects can have hidden prototypes, so we need to traverse 2225 // Note that objects can have hidden prototypes, so we need to traverse
2230 // the whole chain of hidden prototypes to do a 'local' lookup. 2226 // the whole chain of hidden prototypes to do a 'local' lookup.
2227 Object* object = global;
2231 LookupResult lookup(isolate); 2228 LookupResult lookup(isolate);
2232 isolate->context()->global_object()->LocalLookup(*name, &lookup, true); 2229 JSObject::cast(object)->LocalLookup(*name, &lookup, true);
2233 if (lookup.IsInterceptor()) { 2230 if (lookup.IsInterceptor()) {
2231 HandleScope handle_scope(isolate);
2234 PropertyAttributes intercepted = 2232 PropertyAttributes intercepted =
2235 lookup.holder()->GetPropertyAttribute(*name); 2233 lookup.holder()->GetPropertyAttribute(*name);
2236 if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) { 2234 if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) {
2237 // Found an interceptor that's not read only. 2235 // Found an interceptor that's not read only.
2238 if (assign) { 2236 if (assign) {
2239 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 2237 return lookup.holder()->SetProperty(
2240 Handle<Object> result = JSObject::SetPropertyForResult( 2238 &lookup, *name, args[2], attributes, strict_mode_flag);
2241 handle(lookup.holder()), &lookup, name, value, attributes,
2242 strict_mode_flag);
2243 RETURN_IF_EMPTY_HANDLE(isolate, result);
2244 return *result;
2245 } else { 2239 } else {
2246 return isolate->heap()->undefined_value(); 2240 return isolate->heap()->undefined_value();
2247 } 2241 }
2248 } 2242 }
2249 } 2243 }
2250 2244
2245 // Reload global in case the loop above performed a GC.
2246 global = isolate->context()->global_object();
2251 if (assign) { 2247 if (assign) {
2252 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 2248 return global->SetProperty(*name, args[2], attributes, strict_mode_flag);
2253 Handle<GlobalObject> global(isolate->context()->global_object());
2254 Handle<Object> result = JSReceiver::SetProperty(
2255 global, name, value, attributes, strict_mode_flag);
2256 RETURN_IF_EMPTY_HANDLE(isolate, result);
2257 return *result;
2258 } 2249 }
2259 return isolate->heap()->undefined_value(); 2250 return isolate->heap()->undefined_value();
2260 } 2251 }
2261 2252
2262 2253
2263 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstGlobal) { 2254 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstGlobal) {
2264 SealHandleScope shs(isolate); 2255 SealHandleScope shs(isolate);
2265 // All constants are declared with an initial value. The name 2256 // All constants are declared with an initial value. The name
2266 // of the constant is the first argument and the initial value 2257 // of the constant is the first argument and the initial value
2267 // is the second. 2258 // is the second.
(...skipping 2512 matching lines...) Expand 10 before | Expand all | Expand 10 after
4780 4771
4781 4772
4782 MaybeObject* Runtime::HasObjectProperty(Isolate* isolate, 4773 MaybeObject* Runtime::HasObjectProperty(Isolate* isolate,
4783 Handle<JSReceiver> object, 4774 Handle<JSReceiver> object,
4784 Handle<Object> key) { 4775 Handle<Object> key) {
4785 HandleScope scope(isolate); 4776 HandleScope scope(isolate);
4786 4777
4787 // Check if the given key is an array index. 4778 // Check if the given key is an array index.
4788 uint32_t index; 4779 uint32_t index;
4789 if (key->ToArrayIndex(&index)) { 4780 if (key->ToArrayIndex(&index)) {
4790 return isolate->heap()->ToBoolean(JSReceiver::HasElement(object, index)); 4781 return isolate->heap()->ToBoolean(object->HasElement(index));
4791 } 4782 }
4792 4783
4793 // Convert the key to a name - possibly by calling back into JavaScript. 4784 // Convert the key to a name - possibly by calling back into JavaScript.
4794 Handle<Name> name; 4785 Handle<Name> name;
4795 if (key->IsName()) { 4786 if (key->IsName()) {
4796 name = Handle<Name>::cast(key); 4787 name = Handle<Name>::cast(key);
4797 } else { 4788 } else {
4798 bool has_pending_exception = false; 4789 bool has_pending_exception = false;
4799 Handle<Object> converted = 4790 Handle<Object> converted =
4800 Execution::ToString(isolate, key, &has_pending_exception); 4791 Execution::ToString(isolate, key, &has_pending_exception);
4801 if (has_pending_exception) return Failure::Exception(); 4792 if (has_pending_exception) return Failure::Exception();
4802 name = Handle<Name>::cast(converted); 4793 name = Handle<Name>::cast(converted);
4803 } 4794 }
4804 4795
4805 return isolate->heap()->ToBoolean(JSReceiver::HasProperty(object, name)); 4796 return isolate->heap()->ToBoolean(object->HasProperty(*name));
4806 } 4797 }
4807 4798
4808 MaybeObject* Runtime::GetObjectPropertyOrFail( 4799 MaybeObject* Runtime::GetObjectPropertyOrFail(
4809 Isolate* isolate, 4800 Isolate* isolate,
4810 Handle<Object> object, 4801 Handle<Object> object,
4811 Handle<Object> key) { 4802 Handle<Object> key) {
4812 CALL_HEAP_FUNCTION_PASS_EXCEPTION(isolate, 4803 CALL_HEAP_FUNCTION_PASS_EXCEPTION(isolate,
4813 GetObjectProperty(isolate, object, key)); 4804 GetObjectProperty(isolate, object, key));
4814 } 4805 }
4815 4806
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
5130 if (object->IsUndefined() || object->IsNull()) { 5121 if (object->IsUndefined() || object->IsNull()) {
5131 Handle<Object> args[2] = { key, object }; 5122 Handle<Object> args[2] = { key, object };
5132 Handle<Object> error = 5123 Handle<Object> error =
5133 isolate->factory()->NewTypeError("non_object_property_store", 5124 isolate->factory()->NewTypeError("non_object_property_store",
5134 HandleVector(args, 2)); 5125 HandleVector(args, 2));
5135 return isolate->Throw(*error); 5126 return isolate->Throw(*error);
5136 } 5127 }
5137 5128
5138 if (object->IsJSProxy()) { 5129 if (object->IsJSProxy()) {
5139 bool has_pending_exception = false; 5130 bool has_pending_exception = false;
5140 Handle<Object> name_object = key->IsSymbol() 5131 Handle<Object> name = key->IsSymbol()
5141 ? key : Execution::ToString(isolate, key, &has_pending_exception); 5132 ? key : Execution::ToString(isolate, key, &has_pending_exception);
5142 if (has_pending_exception) return Failure::Exception(); 5133 if (has_pending_exception) return Failure::Exception();
5143 Handle<Name> name = Handle<Name>::cast(name_object); 5134 return JSProxy::cast(*object)->SetProperty(
5144 Handle<Object> result = JSReceiver::SetProperty( 5135 Name::cast(*name), *value, attr, strict_mode);
5145 Handle<JSProxy>::cast(object), name, value, attr, strict_mode);
5146 RETURN_IF_EMPTY_HANDLE(isolate, result);
5147 return *result;
5148 } 5136 }
5149 5137
5150 // If the object isn't a JavaScript object, we ignore the store. 5138 // If the object isn't a JavaScript object, we ignore the store.
5151 if (!object->IsJSObject()) return *value; 5139 if (!object->IsJSObject()) return *value;
5152 5140
5153 Handle<JSObject> js_object = Handle<JSObject>::cast(object); 5141 Handle<JSObject> js_object = Handle<JSObject>::cast(object);
5154 5142
5155 // Check if the given key is an array index. 5143 // Check if the given key is an array index.
5156 uint32_t index; 5144 uint32_t index;
5157 if (key->ToArrayIndex(&index)) { 5145 if (key->ToArrayIndex(&index)) {
(...skipping 19 matching lines...) Expand all
5177 } 5165 }
5178 } 5166 }
5179 MaybeObject* result = js_object->SetElement( 5167 MaybeObject* result = js_object->SetElement(
5180 index, *value, attr, strict_mode, true, set_mode); 5168 index, *value, attr, strict_mode, true, set_mode);
5181 js_object->ValidateElements(); 5169 js_object->ValidateElements();
5182 if (result->IsFailure()) return result; 5170 if (result->IsFailure()) return result;
5183 return *value; 5171 return *value;
5184 } 5172 }
5185 5173
5186 if (key->IsName()) { 5174 if (key->IsName()) {
5175 MaybeObject* result;
5187 Handle<Name> name = Handle<Name>::cast(key); 5176 Handle<Name> name = Handle<Name>::cast(key);
5188 if (name->AsArrayIndex(&index)) { 5177 if (name->AsArrayIndex(&index)) {
5189 if (js_object->HasExternalArrayElements()) { 5178 if (js_object->HasExternalArrayElements()) {
5190 if (!value->IsNumber() && !value->IsUndefined()) { 5179 if (!value->IsNumber() && !value->IsUndefined()) {
5191 bool has_exception; 5180 bool has_exception;
5192 Handle<Object> number = 5181 Handle<Object> number =
5193 Execution::ToNumber(isolate, value, &has_exception); 5182 Execution::ToNumber(isolate, value, &has_exception);
5194 if (has_exception) return Failure::Exception(); 5183 if (has_exception) return Failure::Exception();
5195 value = number; 5184 value = number;
5196 } 5185 }
5197 } 5186 }
5198 MaybeObject* result = js_object->SetElement( 5187 result = js_object->SetElement(
5199 index, *value, attr, strict_mode, true, set_mode); 5188 index, *value, attr, strict_mode, true, set_mode);
5200 if (result->IsFailure()) return result;
5201 } else { 5189 } else {
5202 if (name->IsString()) Handle<String>::cast(name)->TryFlatten(); 5190 if (name->IsString()) Handle<String>::cast(name)->TryFlatten();
5203 Handle<Object> result = 5191 result = js_object->SetProperty(*name, *value, attr, strict_mode);
5204 JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
5205 RETURN_IF_EMPTY_HANDLE(isolate, result);
5206 } 5192 }
5193 if (result->IsFailure()) return result;
5207 return *value; 5194 return *value;
5208 } 5195 }
5209 5196
5210 // Call-back into JavaScript to convert the key to a string. 5197 // Call-back into JavaScript to convert the key to a string.
5211 bool has_pending_exception = false; 5198 bool has_pending_exception = false;
5212 Handle<Object> converted = 5199 Handle<Object> converted =
5213 Execution::ToString(isolate, key, &has_pending_exception); 5200 Execution::ToString(isolate, key, &has_pending_exception);
5214 if (has_pending_exception) return Failure::Exception(); 5201 if (has_pending_exception) return Failure::Exception();
5215 Handle<String> name = Handle<String>::cast(converted); 5202 Handle<String> name = Handle<String>::cast(converted);
5216 5203
5217 if (name->AsArrayIndex(&index)) { 5204 if (name->AsArrayIndex(&index)) {
5218 return js_object->SetElement( 5205 return js_object->SetElement(
5219 index, *value, attr, strict_mode, true, set_mode); 5206 index, *value, attr, strict_mode, true, set_mode);
5220 } else { 5207 } else {
5221 Handle<Object> result = 5208 return js_object->SetProperty(*name, *value, attr, strict_mode);
5222 JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
5223 RETURN_IF_EMPTY_HANDLE(isolate, result);
5224 return *result;
5225 } 5209 }
5226 } 5210 }
5227 5211
5228 5212
5229 MaybeObject* Runtime::ForceSetObjectProperty(Isolate* isolate, 5213 MaybeObject* Runtime::ForceSetObjectProperty(Isolate* isolate,
5230 Handle<JSObject> js_object, 5214 Handle<JSObject> js_object,
5231 Handle<Object> key, 5215 Handle<Object> key,
5232 Handle<Object> value, 5216 Handle<Object> value,
5233 PropertyAttributes attr) { 5217 PropertyAttributes attr) {
5234 HandleScope scope(isolate); 5218 HandleScope scope(isolate);
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
5513 ? JSReceiver::STRICT_DELETION : JSReceiver::NORMAL_DELETION; 5497 ? JSReceiver::STRICT_DELETION : JSReceiver::NORMAL_DELETION;
5514 Handle<Object> result = JSReceiver::DeleteProperty(object, key, delete_mode); 5498 Handle<Object> result = JSReceiver::DeleteProperty(object, key, delete_mode);
5515 RETURN_IF_EMPTY_HANDLE(isolate, result); 5499 RETURN_IF_EMPTY_HANDLE(isolate, result);
5516 return *result; 5500 return *result;
5517 } 5501 }
5518 5502
5519 5503
5520 static MaybeObject* HasLocalPropertyImplementation(Isolate* isolate, 5504 static MaybeObject* HasLocalPropertyImplementation(Isolate* isolate,
5521 Handle<JSObject> object, 5505 Handle<JSObject> object,
5522 Handle<Name> key) { 5506 Handle<Name> key) {
5523 if (JSReceiver::HasLocalProperty(object, key)) { 5507 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value();
5524 return isolate->heap()->true_value();
5525 }
5526 // Handle hidden prototypes. If there's a hidden prototype above this thing 5508 // Handle hidden prototypes. If there's a hidden prototype above this thing
5527 // then we have to check it for properties, because they are supposed to 5509 // then we have to check it for properties, because they are supposed to
5528 // look like they are on this object. 5510 // look like they are on this object.
5529 Handle<Object> proto(object->GetPrototype(), isolate); 5511 Handle<Object> proto(object->GetPrototype(), isolate);
5530 if (proto->IsJSObject() && 5512 if (proto->IsJSObject() &&
5531 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { 5513 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) {
5532 return HasLocalPropertyImplementation(isolate, 5514 return HasLocalPropertyImplementation(isolate,
5533 Handle<JSObject>::cast(proto), 5515 Handle<JSObject>::cast(proto),
5534 key); 5516 key);
5535 } 5517 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5575 String* string = String::cast(obj); 5557 String* string = String::cast(obj);
5576 if (index < static_cast<uint32_t>(string->length())) { 5558 if (index < static_cast<uint32_t>(string->length())) {
5577 return isolate->heap()->true_value(); 5559 return isolate->heap()->true_value();
5578 } 5560 }
5579 } 5561 }
5580 return isolate->heap()->false_value(); 5562 return isolate->heap()->false_value();
5581 } 5563 }
5582 5564
5583 5565
5584 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { 5566 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) {
5585 HandleScope scope(isolate); 5567 SealHandleScope shs(isolate);
5586 ASSERT(args.length() == 2); 5568 ASSERT(args.length() == 2);
5587 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); 5569 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0);
5588 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); 5570 CONVERT_ARG_CHECKED(Name, key, 1);
5589 5571
5590 bool result = JSReceiver::HasProperty(receiver, key); 5572 bool result = receiver->HasProperty(key);
5591 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 5573 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
5592 if (isolate->has_pending_exception()) return Failure::Exception(); 5574 if (isolate->has_pending_exception()) return Failure::Exception();
5593 return isolate->heap()->ToBoolean(result); 5575 return isolate->heap()->ToBoolean(result);
5594 } 5576 }
5595 5577
5596 5578
5597 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) { 5579 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) {
5598 HandleScope scope(isolate); 5580 SealHandleScope shs(isolate);
5599 ASSERT(args.length() == 2); 5581 ASSERT(args.length() == 2);
5600 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); 5582 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0);
5601 CONVERT_SMI_ARG_CHECKED(index, 1); 5583 CONVERT_SMI_ARG_CHECKED(index, 1);
5602 5584
5603 bool result = JSReceiver::HasElement(receiver, index); 5585 bool result = receiver->HasElement(index);
5604 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 5586 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
5605 if (isolate->has_pending_exception()) return Failure::Exception(); 5587 if (isolate->has_pending_exception()) return Failure::Exception();
5606 return isolate->heap()->ToBoolean(result); 5588 return isolate->heap()->ToBoolean(result);
5607 } 5589 }
5608 5590
5609 5591
5610 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) { 5592 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) {
5611 SealHandleScope shs(isolate); 5593 SealHandleScope shs(isolate);
5612 ASSERT(args.length() == 2); 5594 ASSERT(args.length() == 2);
5613 5595
(...skipping 3590 matching lines...) Expand 10 before | Expand all | Expand 10 after
9204 UNREACHABLE(); 9186 UNREACHABLE();
9205 return MakePair(NULL, NULL); 9187 return MakePair(NULL, NULL);
9206 } 9188 }
9207 } 9189 }
9208 9190
9209 // Otherwise, if the slot was found the holder is a context extension 9191 // Otherwise, if the slot was found the holder is a context extension
9210 // object, subject of a with, or a global object. We read the named 9192 // object, subject of a with, or a global object. We read the named
9211 // property from it. 9193 // property from it.
9212 if (!holder.is_null()) { 9194 if (!holder.is_null()) {
9213 Handle<JSReceiver> object = Handle<JSReceiver>::cast(holder); 9195 Handle<JSReceiver> object = Handle<JSReceiver>::cast(holder);
9214 ASSERT(object->IsJSProxy() || JSReceiver::HasProperty(object, name)); 9196 ASSERT(object->IsJSProxy() || object->HasProperty(*name));
9215 // GetProperty below can cause GC. 9197 // GetProperty below can cause GC.
9216 Handle<Object> receiver_handle( 9198 Handle<Object> receiver_handle(
9217 object->IsGlobalObject() 9199 object->IsGlobalObject()
9218 ? GlobalObject::cast(*object)->global_receiver() 9200 ? GlobalObject::cast(*object)->global_receiver()
9219 : object->IsJSProxy() ? static_cast<Object*>(*object) 9201 : object->IsJSProxy() ? static_cast<Object*>(*object)
9220 : ComputeReceiverForNonGlobal(isolate, JSObject::cast(*object)), 9202 : ComputeReceiverForNonGlobal(isolate, JSObject::cast(*object)),
9221 isolate); 9203 isolate);
9222 9204
9223 // No need to unhole the value here. This is taken care of by the 9205 // No need to unhole the value here. This is taken care of by the
9224 // GetProperty function. 9206 // GetProperty function.
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
10185 // Run through the elements FixedArray and use HasElement and GetElement 10167 // Run through the elements FixedArray and use HasElement and GetElement
10186 // to check the prototype for missing elements. 10168 // to check the prototype for missing elements.
10187 Handle<FixedArray> elements(FixedArray::cast(receiver->elements())); 10169 Handle<FixedArray> elements(FixedArray::cast(receiver->elements()));
10188 int fast_length = static_cast<int>(length); 10170 int fast_length = static_cast<int>(length);
10189 ASSERT(fast_length <= elements->length()); 10171 ASSERT(fast_length <= elements->length());
10190 for (int j = 0; j < fast_length; j++) { 10172 for (int j = 0; j < fast_length; j++) {
10191 HandleScope loop_scope(isolate); 10173 HandleScope loop_scope(isolate);
10192 Handle<Object> element_value(elements->get(j), isolate); 10174 Handle<Object> element_value(elements->get(j), isolate);
10193 if (!element_value->IsTheHole()) { 10175 if (!element_value->IsTheHole()) {
10194 visitor->visit(j, element_value); 10176 visitor->visit(j, element_value);
10195 } else if (JSReceiver::HasElement(receiver, j)) { 10177 } else if (receiver->HasElement(j)) {
10196 // Call GetElement on receiver, not its prototype, or getters won't 10178 // Call GetElement on receiver, not its prototype, or getters won't
10197 // have the correct receiver. 10179 // have the correct receiver.
10198 element_value = Object::GetElement(isolate, receiver, j); 10180 element_value = Object::GetElement(isolate, receiver, j);
10199 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element_value, false); 10181 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element_value, false);
10200 visitor->visit(j, element_value); 10182 visitor->visit(j, element_value);
10201 } 10183 }
10202 } 10184 }
10203 break; 10185 break;
10204 } 10186 }
10205 case FAST_HOLEY_DOUBLE_ELEMENTS: 10187 case FAST_HOLEY_DOUBLE_ELEMENTS:
10206 case FAST_DOUBLE_ELEMENTS: { 10188 case FAST_DOUBLE_ELEMENTS: {
10207 // Run through the elements FixedArray and use HasElement and GetElement 10189 // Run through the elements FixedArray and use HasElement and GetElement
10208 // to check the prototype for missing elements. 10190 // to check the prototype for missing elements.
10209 Handle<FixedDoubleArray> elements( 10191 Handle<FixedDoubleArray> elements(
10210 FixedDoubleArray::cast(receiver->elements())); 10192 FixedDoubleArray::cast(receiver->elements()));
10211 int fast_length = static_cast<int>(length); 10193 int fast_length = static_cast<int>(length);
10212 ASSERT(fast_length <= elements->length()); 10194 ASSERT(fast_length <= elements->length());
10213 for (int j = 0; j < fast_length; j++) { 10195 for (int j = 0; j < fast_length; j++) {
10214 HandleScope loop_scope(isolate); 10196 HandleScope loop_scope(isolate);
10215 if (!elements->is_the_hole(j)) { 10197 if (!elements->is_the_hole(j)) {
10216 double double_value = elements->get_scalar(j); 10198 double double_value = elements->get_scalar(j);
10217 Handle<Object> element_value = 10199 Handle<Object> element_value =
10218 isolate->factory()->NewNumber(double_value); 10200 isolate->factory()->NewNumber(double_value);
10219 visitor->visit(j, element_value); 10201 visitor->visit(j, element_value);
10220 } else if (JSReceiver::HasElement(receiver, j)) { 10202 } else if (receiver->HasElement(j)) {
10221 // Call GetElement on receiver, not its prototype, or getters won't 10203 // Call GetElement on receiver, not its prototype, or getters won't
10222 // have the correct receiver. 10204 // have the correct receiver.
10223 Handle<Object> element_value = 10205 Handle<Object> element_value =
10224 Object::GetElement(isolate, receiver, j); 10206 Object::GetElement(isolate, receiver, j);
10225 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element_value, false); 10207 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element_value, false);
10226 visitor->visit(j, element_value); 10208 visitor->visit(j, element_value);
10227 } 10209 }
10228 } 10210 }
10229 break; 10211 break;
10230 } 10212 }
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after
11526 isolate, scope_info, function_context, variable_name, new_value)) { 11508 isolate, scope_info, function_context, variable_name, new_value)) {
11527 return true; 11509 return true;
11528 } 11510 }
11529 11511
11530 // Function context extension. These are variables introduced by eval. 11512 // Function context extension. These are variables introduced by eval.
11531 if (function_context->closure() == *function) { 11513 if (function_context->closure() == *function) {
11532 if (function_context->has_extension() && 11514 if (function_context->has_extension() &&
11533 !function_context->IsNativeContext()) { 11515 !function_context->IsNativeContext()) {
11534 Handle<JSObject> ext(JSObject::cast(function_context->extension())); 11516 Handle<JSObject> ext(JSObject::cast(function_context->extension()));
11535 11517
11536 if (JSReceiver::HasProperty(ext, variable_name)) { 11518 if (ext->HasProperty(*variable_name)) {
11537 // We don't expect this to do anything except replacing 11519 // We don't expect this to do anything except replacing
11538 // property value. 11520 // property value.
11539 SetProperty(isolate, 11521 SetProperty(isolate,
11540 ext, 11522 ext,
11541 variable_name, 11523 variable_name,
11542 new_value, 11524 new_value,
11543 NONE, 11525 NONE,
11544 kNonStrictMode); 11526 kNonStrictMode);
11545 return true; 11527 return true;
11546 } 11528 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
11614 // Context locals to the context extension. 11596 // Context locals to the context extension.
11615 if (SetContextLocalValue( 11597 if (SetContextLocalValue(
11616 isolate, scope_info, context, variable_name, new_value)) { 11598 isolate, scope_info, context, variable_name, new_value)) {
11617 return true; 11599 return true;
11618 } 11600 }
11619 11601
11620 // Properties from the function context extension. This will 11602 // Properties from the function context extension. This will
11621 // be variables introduced by eval. 11603 // be variables introduced by eval.
11622 if (context->has_extension()) { 11604 if (context->has_extension()) {
11623 Handle<JSObject> ext(JSObject::cast(context->extension())); 11605 Handle<JSObject> ext(JSObject::cast(context->extension()));
11624 if (JSReceiver::HasProperty(ext, variable_name)) { 11606 if (ext->HasProperty(*variable_name)) {
11625 // We don't expect this to do anything except replacing property value. 11607 // We don't expect this to do anything except replacing property value.
11626 SetProperty(isolate, 11608 SetProperty(isolate,
11627 ext, 11609 ext,
11628 variable_name, 11610 variable_name,
11629 new_value, 11611 new_value,
11630 NONE, 11612 NONE,
11631 kNonStrictMode); 11613 kNonStrictMode);
11632 return true; 11614 return true;
11633 } 11615 }
11634 } 11616 }
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
12657 12639
12658 // Helper function to find or create the arguments object for 12640 // Helper function to find or create the arguments object for
12659 // Runtime_DebugEvaluate. 12641 // Runtime_DebugEvaluate.
12660 static Handle<JSObject> MaterializeArgumentsObject( 12642 static Handle<JSObject> MaterializeArgumentsObject(
12661 Isolate* isolate, 12643 Isolate* isolate,
12662 Handle<JSObject> target, 12644 Handle<JSObject> target,
12663 Handle<JSFunction> function) { 12645 Handle<JSFunction> function) {
12664 // Do not materialize the arguments object for eval or top-level code. 12646 // Do not materialize the arguments object for eval or top-level code.
12665 // Skip if "arguments" is already taken. 12647 // Skip if "arguments" is already taken.
12666 if (!function->shared()->is_function() || 12648 if (!function->shared()->is_function() ||
12667 JSReceiver::HasLocalProperty(target, 12649 target->HasLocalProperty(isolate->heap()->arguments_string())) {
12668 isolate->factory()->arguments_string())) {
12669 return target; 12650 return target;
12670 } 12651 }
12671 12652
12672 // FunctionGetArguments can't throw an exception. 12653 // FunctionGetArguments can't throw an exception.
12673 Handle<JSObject> arguments = Handle<JSObject>::cast( 12654 Handle<JSObject> arguments = Handle<JSObject>::cast(
12674 Accessors::FunctionGetArguments(function)); 12655 Accessors::FunctionGetArguments(function));
12675 SetProperty(isolate, 12656 SetProperty(isolate,
12676 target, 12657 target,
12677 isolate->factory()->arguments_string(), 12658 isolate->factory()->arguments_string(),
12678 arguments, 12659 arguments,
(...skipping 2119 matching lines...) Expand 10 before | Expand all | Expand 10 after
14798 } 14779 }
14799 return NULL; 14780 return NULL;
14800 } 14781 }
14801 14782
14802 14783
14803 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 14784 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
14804 return &(kIntrinsicFunctions[static_cast<int>(id)]); 14785 return &(kIntrinsicFunctions[static_cast<int>(id)]);
14805 } 14786 }
14806 14787
14807 14788
14808 void Runtime::PerformGC(Object* result, Isolate* isolate) { 14789 void Runtime::PerformGC(Object* result) {
14790 Isolate* isolate = Isolate::Current();
14809 Failure* failure = Failure::cast(result); 14791 Failure* failure = Failure::cast(result);
14810 if (failure->IsRetryAfterGC()) { 14792 if (failure->IsRetryAfterGC()) {
14811 if (isolate->heap()->new_space()->AddFreshPage()) { 14793 if (isolate->heap()->new_space()->AddFreshPage()) {
14812 return; 14794 return;
14813 } 14795 }
14814 14796
14815 // Try to do a garbage collection; ignore it if it fails. The C 14797 // Try to do a garbage collection; ignore it if it fails. The C
14816 // entry stub will throw an out-of-memory exception in that case. 14798 // entry stub will throw an out-of-memory exception in that case.
14817 isolate->heap()->CollectGarbage(failure->allocation_space(), 14799 isolate->heap()->CollectGarbage(failure->allocation_space(),
14818 "Runtime::PerformGC"); 14800 "Runtime::PerformGC");
14819 } else { 14801 } else {
14820 // Handle last resort GC and make sure to allow future allocations 14802 // Handle last resort GC and make sure to allow future allocations
14821 // to grow the heap without causing GCs (if possible). 14803 // to grow the heap without causing GCs (if possible).
14822 isolate->counters()->gc_last_resort_from_js()->Increment(); 14804 isolate->counters()->gc_last_resort_from_js()->Increment();
14823 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14805 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14824 "Runtime::PerformGC"); 14806 "Runtime::PerformGC");
14825 } 14807 }
14826 } 14808 }
14827 14809
14828 14810
14829 } } // namespace v8::internal 14811 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/stub-cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698