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

Side by Side Diff: src/runtime.cc

Issue 151603004: A64: Synchronize with r16587. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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/runtime-profiler.cc » ('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 2451 matching lines...) Expand 10 before | Expand all | Expand 10 after
2462 SealHandleScope shs(isolate); 2462 SealHandleScope shs(isolate);
2463 ASSERT(args.length() == 3); 2463 ASSERT(args.length() == 3);
2464 CONVERT_SMI_ARG_CHECKED(elements_count, 0); 2464 CONVERT_SMI_ARG_CHECKED(elements_count, 0);
2465 if (elements_count < 0 || 2465 if (elements_count < 0 ||
2466 elements_count > FixedArray::kMaxLength || 2466 elements_count > FixedArray::kMaxLength ||
2467 !Smi::IsValid(elements_count)) { 2467 !Smi::IsValid(elements_count)) {
2468 return isolate->ThrowIllegalOperation(); 2468 return isolate->ThrowIllegalOperation();
2469 } 2469 }
2470 Object* new_object; 2470 Object* new_object;
2471 { MaybeObject* maybe_new_object = 2471 { MaybeObject* maybe_new_object =
2472 isolate->heap()->AllocateFixedArrayWithHoles(elements_count); 2472 isolate->heap()->AllocateFixedArray(elements_count);
2473 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; 2473 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object;
2474 } 2474 }
2475 FixedArray* elements = FixedArray::cast(new_object); 2475 FixedArray* elements = FixedArray::cast(new_object);
2476 { MaybeObject* maybe_new_object = isolate->heap()->AllocateRaw( 2476 { MaybeObject* maybe_new_object = isolate->heap()->AllocateRaw(
2477 JSRegExpResult::kSize, NEW_SPACE, OLD_POINTER_SPACE); 2477 JSRegExpResult::kSize, NEW_SPACE, OLD_POINTER_SPACE);
2478 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; 2478 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object;
2479 } 2479 }
2480 { 2480 {
2481 DisallowHeapAllocation no_gc; 2481 DisallowHeapAllocation no_gc;
2482 HandleScope scope(isolate); 2482 HandleScope scope(isolate);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2614 } 2614 }
2615 2615
2616 2616
2617 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsClassicModeFunction) { 2617 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsClassicModeFunction) {
2618 SealHandleScope shs(isolate); 2618 SealHandleScope shs(isolate);
2619 ASSERT(args.length() == 1); 2619 ASSERT(args.length() == 1);
2620 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); 2620 CONVERT_ARG_CHECKED(JSReceiver, callable, 0);
2621 if (!callable->IsJSFunction()) { 2621 if (!callable->IsJSFunction()) {
2622 HandleScope scope(isolate); 2622 HandleScope scope(isolate);
2623 bool threw = false; 2623 bool threw = false;
2624 Handle<Object> delegate = 2624 Handle<Object> delegate = Execution::TryGetFunctionDelegate(
2625 Execution::TryGetFunctionDelegate(Handle<JSReceiver>(callable), &threw); 2625 isolate, Handle<JSReceiver>(callable), &threw);
2626 if (threw) return Failure::Exception(); 2626 if (threw) return Failure::Exception();
2627 callable = JSFunction::cast(*delegate); 2627 callable = JSFunction::cast(*delegate);
2628 } 2628 }
2629 JSFunction* function = JSFunction::cast(callable); 2629 JSFunction* function = JSFunction::cast(callable);
2630 SharedFunctionInfo* shared = function->shared(); 2630 SharedFunctionInfo* shared = function->shared();
2631 return isolate->heap()->ToBoolean(shared->is_classic_mode()); 2631 return isolate->heap()->ToBoolean(shared->is_classic_mode());
2632 } 2632 }
2633 2633
2634 2634
2635 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) { 2635 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) {
2636 SealHandleScope shs(isolate); 2636 SealHandleScope shs(isolate);
2637 ASSERT(args.length() == 1); 2637 ASSERT(args.length() == 1);
2638 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); 2638 CONVERT_ARG_CHECKED(JSReceiver, callable, 0);
2639 2639
2640 if (!callable->IsJSFunction()) { 2640 if (!callable->IsJSFunction()) {
2641 HandleScope scope(isolate); 2641 HandleScope scope(isolate);
2642 bool threw = false; 2642 bool threw = false;
2643 Handle<Object> delegate = 2643 Handle<Object> delegate = Execution::TryGetFunctionDelegate(
2644 Execution::TryGetFunctionDelegate(Handle<JSReceiver>(callable), &threw); 2644 isolate, Handle<JSReceiver>(callable), &threw);
2645 if (threw) return Failure::Exception(); 2645 if (threw) return Failure::Exception();
2646 callable = JSFunction::cast(*delegate); 2646 callable = JSFunction::cast(*delegate);
2647 } 2647 }
2648 JSFunction* function = JSFunction::cast(callable); 2648 JSFunction* function = JSFunction::cast(callable);
2649 2649
2650 SharedFunctionInfo* shared = function->shared(); 2650 SharedFunctionInfo* shared = function->shared();
2651 if (shared->native() || !shared->is_classic_mode()) { 2651 if (shared->native() || !shared->is_classic_mode()) {
2652 return isolate->heap()->undefined_value(); 2652 return isolate->heap()->undefined_value();
2653 } 2653 }
2654 // Returns undefined for strict or native functions, or 2654 // Returns undefined for strict or native functions, or
(...skipping 2112 matching lines...) Expand 10 before | Expand all | Expand 10 after
4767 4767
4768 // Handle [] indexing on String objects 4768 // Handle [] indexing on String objects
4769 if (object->IsStringObjectWithCharacterAt(index)) { 4769 if (object->IsStringObjectWithCharacterAt(index)) {
4770 Handle<JSValue> js_value = Handle<JSValue>::cast(object); 4770 Handle<JSValue> js_value = Handle<JSValue>::cast(object);
4771 Handle<Object> result = 4771 Handle<Object> result =
4772 GetCharAt(Handle<String>(String::cast(js_value->value())), index); 4772 GetCharAt(Handle<String>(String::cast(js_value->value())), index);
4773 if (!result->IsUndefined()) return *result; 4773 if (!result->IsUndefined()) return *result;
4774 } 4774 }
4775 4775
4776 if (object->IsString() || object->IsNumber() || object->IsBoolean()) { 4776 if (object->IsString() || object->IsNumber() || object->IsBoolean()) {
4777 return object->GetPrototype(isolate)->GetElement(index); 4777 return object->GetPrototype(isolate)->GetElement(isolate, index);
4778 } 4778 }
4779 4779
4780 return object->GetElement(index); 4780 return object->GetElement(isolate, index);
4781 } 4781 }
4782 4782
4783 4783
4784 MaybeObject* Runtime::HasObjectProperty(Isolate* isolate, 4784 MaybeObject* Runtime::HasObjectProperty(Isolate* isolate,
4785 Handle<JSReceiver> object, 4785 Handle<JSReceiver> object,
4786 Handle<Object> key) { 4786 Handle<Object> key) {
4787 HandleScope scope(isolate); 4787 HandleScope scope(isolate);
4788 4788
4789 // Check if the given key is an array index. 4789 // Check if the given key is an array index.
4790 uint32_t index; 4790 uint32_t index;
4791 if (key->ToArrayIndex(&index)) { 4791 if (key->ToArrayIndex(&index)) {
4792 return isolate->heap()->ToBoolean(object->HasElement(index)); 4792 return isolate->heap()->ToBoolean(object->HasElement(index));
4793 } 4793 }
4794 4794
4795 // Convert the key to a name - possibly by calling back into JavaScript. 4795 // Convert the key to a name - possibly by calling back into JavaScript.
4796 Handle<Name> name; 4796 Handle<Name> name;
4797 if (key->IsName()) { 4797 if (key->IsName()) {
4798 name = Handle<Name>::cast(key); 4798 name = Handle<Name>::cast(key);
4799 } else { 4799 } else {
4800 bool has_pending_exception = false; 4800 bool has_pending_exception = false;
4801 Handle<Object> converted = 4801 Handle<Object> converted =
4802 Execution::ToString(key, &has_pending_exception); 4802 Execution::ToString(isolate, key, &has_pending_exception);
4803 if (has_pending_exception) return Failure::Exception(); 4803 if (has_pending_exception) return Failure::Exception();
4804 name = Handle<Name>::cast(converted); 4804 name = Handle<Name>::cast(converted);
4805 } 4805 }
4806 4806
4807 return isolate->heap()->ToBoolean(object->HasProperty(*name)); 4807 return isolate->heap()->ToBoolean(object->HasProperty(*name));
4808 } 4808 }
4809 4809
4810 MaybeObject* Runtime::GetObjectPropertyOrFail( 4810 MaybeObject* Runtime::GetObjectPropertyOrFail(
4811 Isolate* isolate, 4811 Isolate* isolate,
4812 Handle<Object> object, 4812 Handle<Object> object,
(...skipping 21 matching lines...) Expand all
4834 return GetElementOrCharAt(isolate, object, index); 4834 return GetElementOrCharAt(isolate, object, index);
4835 } 4835 }
4836 4836
4837 // Convert the key to a name - possibly by calling back into JavaScript. 4837 // Convert the key to a name - possibly by calling back into JavaScript.
4838 Handle<Name> name; 4838 Handle<Name> name;
4839 if (key->IsName()) { 4839 if (key->IsName()) {
4840 name = Handle<Name>::cast(key); 4840 name = Handle<Name>::cast(key);
4841 } else { 4841 } else {
4842 bool has_pending_exception = false; 4842 bool has_pending_exception = false;
4843 Handle<Object> converted = 4843 Handle<Object> converted =
4844 Execution::ToString(key, &has_pending_exception); 4844 Execution::ToString(isolate, key, &has_pending_exception);
4845 if (has_pending_exception) return Failure::Exception(); 4845 if (has_pending_exception) return Failure::Exception();
4846 name = Handle<Name>::cast(converted); 4846 name = Handle<Name>::cast(converted);
4847 } 4847 }
4848 4848
4849 // Check if the name is trivially convertible to an index and get 4849 // Check if the name is trivially convertible to an index and get
4850 // the element if so. 4850 // the element if so.
4851 if (name->AsArrayIndex(&index)) { 4851 if (name->AsArrayIndex(&index)) {
4852 return GetElementOrCharAt(isolate, object, index); 4852 return GetElementOrCharAt(isolate, object, index);
4853 } else { 4853 } else {
4854 return object->GetProperty(*name); 4854 return object->GetProperty(*name);
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
5132 Handle<Object> args[2] = { key, object }; 5132 Handle<Object> args[2] = { key, object };
5133 Handle<Object> error = 5133 Handle<Object> error =
5134 isolate->factory()->NewTypeError("non_object_property_store", 5134 isolate->factory()->NewTypeError("non_object_property_store",
5135 HandleVector(args, 2)); 5135 HandleVector(args, 2));
5136 return isolate->Throw(*error); 5136 return isolate->Throw(*error);
5137 } 5137 }
5138 5138
5139 if (object->IsJSProxy()) { 5139 if (object->IsJSProxy()) {
5140 bool has_pending_exception = false; 5140 bool has_pending_exception = false;
5141 Handle<Object> name = key->IsSymbol() 5141 Handle<Object> name = key->IsSymbol()
5142 ? key : Execution::ToString(key, &has_pending_exception); 5142 ? key : Execution::ToString(isolate, key, &has_pending_exception);
5143 if (has_pending_exception) return Failure::Exception(); 5143 if (has_pending_exception) return Failure::Exception();
5144 return JSProxy::cast(*object)->SetProperty( 5144 return JSProxy::cast(*object)->SetProperty(
5145 Name::cast(*name), *value, attr, strict_mode); 5145 Name::cast(*name), *value, attr, strict_mode);
5146 } 5146 }
5147 5147
5148 // If the object isn't a JavaScript object, we ignore the store. 5148 // If the object isn't a JavaScript object, we ignore the store.
5149 if (!object->IsJSObject()) return *value; 5149 if (!object->IsJSObject()) return *value;
5150 5150
5151 Handle<JSObject> js_object = Handle<JSObject>::cast(object); 5151 Handle<JSObject> js_object = Handle<JSObject>::cast(object);
5152 5152
5153 // Check if the given key is an array index. 5153 // Check if the given key is an array index.
5154 uint32_t index; 5154 uint32_t index;
5155 if (key->ToArrayIndex(&index)) { 5155 if (key->ToArrayIndex(&index)) {
5156 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters 5156 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters
5157 // of a string using [] notation. We need to support this too in 5157 // of a string using [] notation. We need to support this too in
5158 // JavaScript. 5158 // JavaScript.
5159 // In the case of a String object we just need to redirect the assignment to 5159 // In the case of a String object we just need to redirect the assignment to
5160 // the underlying string if the index is in range. Since the underlying 5160 // the underlying string if the index is in range. Since the underlying
5161 // string does nothing with the assignment then we can ignore such 5161 // string does nothing with the assignment then we can ignore such
5162 // assignments. 5162 // assignments.
5163 if (js_object->IsStringObjectWithCharacterAt(index)) { 5163 if (js_object->IsStringObjectWithCharacterAt(index)) {
5164 return *value; 5164 return *value;
5165 } 5165 }
5166 5166
5167 js_object->ValidateElements(); 5167 js_object->ValidateElements();
5168 if (js_object->HasExternalArrayElements()) { 5168 if (js_object->HasExternalArrayElements()) {
5169 if (!value->IsNumber() && !value->IsUndefined()) { 5169 if (!value->IsNumber() && !value->IsUndefined()) {
5170 bool has_exception; 5170 bool has_exception;
5171 Handle<Object> number = Execution::ToNumber(value, &has_exception); 5171 Handle<Object> number =
5172 Execution::ToNumber(isolate, value, &has_exception);
5172 if (has_exception) return Failure::Exception(); 5173 if (has_exception) return Failure::Exception();
5173 value = number; 5174 value = number;
5174 } 5175 }
5175 } 5176 }
5176 MaybeObject* result = js_object->SetElement( 5177 MaybeObject* result = js_object->SetElement(
5177 index, *value, attr, strict_mode, true, set_mode); 5178 index, *value, attr, strict_mode, true, set_mode);
5178 js_object->ValidateElements(); 5179 js_object->ValidateElements();
5179 if (result->IsFailure()) return result; 5180 if (result->IsFailure()) return result;
5180 return *value; 5181 return *value;
5181 } 5182 }
5182 5183
5183 if (key->IsName()) { 5184 if (key->IsName()) {
5184 MaybeObject* result; 5185 MaybeObject* result;
5185 Handle<Name> name = Handle<Name>::cast(key); 5186 Handle<Name> name = Handle<Name>::cast(key);
5186 if (name->AsArrayIndex(&index)) { 5187 if (name->AsArrayIndex(&index)) {
5187 if (js_object->HasExternalArrayElements()) { 5188 if (js_object->HasExternalArrayElements()) {
5188 if (!value->IsNumber() && !value->IsUndefined()) { 5189 if (!value->IsNumber() && !value->IsUndefined()) {
5189 bool has_exception; 5190 bool has_exception;
5190 Handle<Object> number = Execution::ToNumber(value, &has_exception); 5191 Handle<Object> number =
5192 Execution::ToNumber(isolate, value, &has_exception);
5191 if (has_exception) return Failure::Exception(); 5193 if (has_exception) return Failure::Exception();
5192 value = number; 5194 value = number;
5193 } 5195 }
5194 } 5196 }
5195 result = js_object->SetElement( 5197 result = js_object->SetElement(
5196 index, *value, attr, strict_mode, true, set_mode); 5198 index, *value, attr, strict_mode, true, set_mode);
5197 } else { 5199 } else {
5198 if (name->IsString()) Handle<String>::cast(name)->TryFlatten(); 5200 if (name->IsString()) Handle<String>::cast(name)->TryFlatten();
5199 result = js_object->SetProperty(*name, *value, attr, strict_mode); 5201 result = js_object->SetProperty(*name, *value, attr, strict_mode);
5200 } 5202 }
5201 if (result->IsFailure()) return result; 5203 if (result->IsFailure()) return result;
5202 return *value; 5204 return *value;
5203 } 5205 }
5204 5206
5205 // Call-back into JavaScript to convert the key to a string. 5207 // Call-back into JavaScript to convert the key to a string.
5206 bool has_pending_exception = false; 5208 bool has_pending_exception = false;
5207 Handle<Object> converted = Execution::ToString(key, &has_pending_exception); 5209 Handle<Object> converted =
5210 Execution::ToString(isolate, key, &has_pending_exception);
5208 if (has_pending_exception) return Failure::Exception(); 5211 if (has_pending_exception) return Failure::Exception();
5209 Handle<String> name = Handle<String>::cast(converted); 5212 Handle<String> name = Handle<String>::cast(converted);
5210 5213
5211 if (name->AsArrayIndex(&index)) { 5214 if (name->AsArrayIndex(&index)) {
5212 return js_object->SetElement( 5215 return js_object->SetElement(
5213 index, *value, attr, strict_mode, true, set_mode); 5216 index, *value, attr, strict_mode, true, set_mode);
5214 } else { 5217 } else {
5215 return js_object->SetProperty(*name, *value, attr, strict_mode); 5218 return js_object->SetProperty(*name, *value, attr, strict_mode);
5216 } 5219 }
5217 } 5220 }
(...skipping 30 matching lines...) Expand all
5248 return js_object->SetElement( 5251 return js_object->SetElement(
5249 index, *value, attr, kNonStrictMode, false, DEFINE_PROPERTY); 5252 index, *value, attr, kNonStrictMode, false, DEFINE_PROPERTY);
5250 } else { 5253 } else {
5251 if (name->IsString()) Handle<String>::cast(name)->TryFlatten(); 5254 if (name->IsString()) Handle<String>::cast(name)->TryFlatten();
5252 return js_object->SetLocalPropertyIgnoreAttributes(*name, *value, attr); 5255 return js_object->SetLocalPropertyIgnoreAttributes(*name, *value, attr);
5253 } 5256 }
5254 } 5257 }
5255 5258
5256 // Call-back into JavaScript to convert the key to a string. 5259 // Call-back into JavaScript to convert the key to a string.
5257 bool has_pending_exception = false; 5260 bool has_pending_exception = false;
5258 Handle<Object> converted = Execution::ToString(key, &has_pending_exception); 5261 Handle<Object> converted =
5262 Execution::ToString(isolate, key, &has_pending_exception);
5259 if (has_pending_exception) return Failure::Exception(); 5263 if (has_pending_exception) return Failure::Exception();
5260 Handle<String> name = Handle<String>::cast(converted); 5264 Handle<String> name = Handle<String>::cast(converted);
5261 5265
5262 if (name->AsArrayIndex(&index)) { 5266 if (name->AsArrayIndex(&index)) {
5263 return js_object->SetElement( 5267 return js_object->SetElement(
5264 index, *value, attr, kNonStrictMode, false, DEFINE_PROPERTY); 5268 index, *value, attr, kNonStrictMode, false, DEFINE_PROPERTY);
5265 } else { 5269 } else {
5266 return js_object->SetLocalPropertyIgnoreAttributes(*name, *value, attr); 5270 return js_object->SetLocalPropertyIgnoreAttributes(*name, *value, attr);
5267 } 5271 }
5268 } 5272 }
(...skipping 22 matching lines...) Expand all
5291 RETURN_IF_EMPTY_HANDLE(isolate, result); 5295 RETURN_IF_EMPTY_HANDLE(isolate, result);
5292 return *result; 5296 return *result;
5293 } 5297 }
5294 5298
5295 Handle<Name> name; 5299 Handle<Name> name;
5296 if (key->IsName()) { 5300 if (key->IsName()) {
5297 name = Handle<Name>::cast(key); 5301 name = Handle<Name>::cast(key);
5298 } else { 5302 } else {
5299 // Call-back into JavaScript to convert the key to a string. 5303 // Call-back into JavaScript to convert the key to a string.
5300 bool has_pending_exception = false; 5304 bool has_pending_exception = false;
5301 Handle<Object> converted = Execution::ToString(key, &has_pending_exception); 5305 Handle<Object> converted = Execution::ToString(
5306 isolate, key, &has_pending_exception);
5302 if (has_pending_exception) return Failure::Exception(); 5307 if (has_pending_exception) return Failure::Exception();
5303 name = Handle<String>::cast(converted); 5308 name = Handle<String>::cast(converted);
5304 } 5309 }
5305 5310
5306 if (name->IsString()) Handle<String>::cast(name)->TryFlatten(); 5311 if (name->IsString()) Handle<String>::cast(name)->TryFlatten();
5307 Handle<Object> result = JSReceiver::DeleteProperty(receiver, name, mode); 5312 Handle<Object> result = JSReceiver::DeleteProperty(receiver, name, mode);
5308 RETURN_IF_EMPTY_HANDLE(isolate, result); 5313 RETURN_IF_EMPTY_HANDLE(isolate, result);
5309 return *result; 5314 return *result;
5310 } 5315 }
5311 5316
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
5883 if (args[0]->IsSymbol()) { 5888 if (args[0]->IsSymbol()) {
5884 // Lookup in the initial Object.prototype object. 5889 // Lookup in the initial Object.prototype object.
5885 return isolate->initial_object_prototype()->GetProperty( 5890 return isolate->initial_object_prototype()->GetProperty(
5886 Symbol::cast(args[0])); 5891 Symbol::cast(args[0]));
5887 } 5892 }
5888 5893
5889 // Convert the key to a string. 5894 // Convert the key to a string.
5890 HandleScope scope(isolate); 5895 HandleScope scope(isolate);
5891 bool exception = false; 5896 bool exception = false;
5892 Handle<Object> converted = 5897 Handle<Object> converted =
5893 Execution::ToString(args.at<Object>(0), &exception); 5898 Execution::ToString(isolate, args.at<Object>(0), &exception);
5894 if (exception) return Failure::Exception(); 5899 if (exception) return Failure::Exception();
5895 Handle<String> key = Handle<String>::cast(converted); 5900 Handle<String> key = Handle<String>::cast(converted);
5896 5901
5897 // Try to convert the string key into an array index. 5902 // Try to convert the string key into an array index.
5898 if (key->AsArrayIndex(&index)) { 5903 if (key->AsArrayIndex(&index)) {
5899 if (index < n) { 5904 if (index < n) {
5900 return frame->GetParameter(index); 5905 return frame->GetParameter(index);
5901 } else { 5906 } else {
5902 return isolate->initial_object_prototype()->GetElement(index); 5907 return isolate->initial_object_prototype()->GetElement(isolate, index);
5903 } 5908 }
5904 } 5909 }
5905 5910
5906 // Handle special arguments properties. 5911 // Handle special arguments properties.
5907 if (key->Equals(isolate->heap()->length_string())) return Smi::FromInt(n); 5912 if (key->Equals(isolate->heap()->length_string())) return Smi::FromInt(n);
5908 if (key->Equals(isolate->heap()->callee_string())) { 5913 if (key->Equals(isolate->heap()->callee_string())) {
5909 JSFunction* function = frame->function(); 5914 JSFunction* function = frame->function();
5910 if (!function->shared()->is_classic_mode()) { 5915 if (!function->shared()->is_classic_mode()) {
5911 return isolate->Throw(*isolate->factory()->NewTypeError( 5916 return isolate->Throw(*isolate->factory()->NewTypeError(
5912 "strict_arguments_callee", HandleVector<Object>(NULL, 0))); 5917 "strict_arguments_callee", HandleVector<Object>(NULL, 0)));
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
6667 #endif 6672 #endif
6668 6673
6669 return *isolate->factory()->NewJSArrayWithElements(elements); 6674 return *isolate->factory()->NewJSArrayWithElements(elements);
6670 } 6675 }
6671 6676
6672 6677
6673 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStringWrapper) { 6678 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStringWrapper) {
6674 SealHandleScope shs(isolate); 6679 SealHandleScope shs(isolate);
6675 ASSERT(args.length() == 1); 6680 ASSERT(args.length() == 1);
6676 CONVERT_ARG_CHECKED(String, value, 0); 6681 CONVERT_ARG_CHECKED(String, value, 0);
6677 return value->ToObject(); 6682 return value->ToObject(isolate);
6678 } 6683 }
6679 6684
6680 6685
6681 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { 6686 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) {
6682 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; 6687 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth];
6683 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); 6688 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars);
6684 return char_length == 0; 6689 return char_length == 0;
6685 } 6690 }
6686 6691
6687 6692
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
7516 r = CompareChars(x_chars.start(), y_chars.start(), prefix_length); 7521 r = CompareChars(x_chars.start(), y_chars.start(), prefix_length);
7517 } 7522 }
7518 } 7523 }
7519 Object* result; 7524 Object* result;
7520 if (r == 0) { 7525 if (r == 0) {
7521 result = equal_prefix_result; 7526 result = equal_prefix_result;
7522 } else { 7527 } else {
7523 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); 7528 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER);
7524 } 7529 }
7525 ASSERT(result == 7530 ASSERT(result ==
7526 StringCharacterStreamCompare(Isolate::Current()->runtime_state(), x, y)); 7531 StringCharacterStreamCompare(x->GetIsolate()->runtime_state(), x, y));
7527 return result; 7532 return result;
7528 } 7533 }
7529 7534
7530 7535
7531 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCompare) { 7536 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCompare) {
7532 SealHandleScope shs(isolate); 7537 SealHandleScope shs(isolate);
7533 ASSERT(args.length() == 2); 7538 ASSERT(args.length() == 2);
7534 7539
7535 CONVERT_ARG_CHECKED(String, x, 0); 7540 CONVERT_ARG_CHECKED(String, x, 0);
7536 CONVERT_ARG_CHECKED(String, y, 1); 7541 CONVERT_ARG_CHECKED(String, y, 1);
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
8144 int total_argc = 0; 8149 int total_argc = 0;
8145 SmartArrayPointer<Handle<Object> > param_data = 8150 SmartArrayPointer<Handle<Object> > param_data =
8146 GetCallerArguments(isolate, bound_argc, &total_argc); 8151 GetCallerArguments(isolate, bound_argc, &total_argc);
8147 for (int i = 0; i < bound_argc; i++) { 8152 for (int i = 0; i < bound_argc; i++) {
8148 param_data[i] = Handle<Object>(bound_args->get( 8153 param_data[i] = Handle<Object>(bound_args->get(
8149 JSFunction::kBoundArgumentsStartIndex + i), isolate); 8154 JSFunction::kBoundArgumentsStartIndex + i), isolate);
8150 } 8155 }
8151 8156
8152 if (!bound_function->IsJSFunction()) { 8157 if (!bound_function->IsJSFunction()) {
8153 bool exception_thrown; 8158 bool exception_thrown;
8154 bound_function = Execution::TryGetConstructorDelegate(bound_function, 8159 bound_function = Execution::TryGetConstructorDelegate(isolate,
8160 bound_function,
8155 &exception_thrown); 8161 &exception_thrown);
8156 if (exception_thrown) return Failure::Exception(); 8162 if (exception_thrown) return Failure::Exception();
8157 } 8163 }
8158 ASSERT(bound_function->IsJSFunction()); 8164 ASSERT(bound_function->IsJSFunction());
8159 8165
8160 bool exception = false; 8166 bool exception = false;
8161 Handle<Object> result = 8167 Handle<Object> result =
8162 Execution::New(Handle<JSFunction>::cast(bound_function), 8168 Execution::New(Handle<JSFunction>::cast(bound_function),
8163 total_argc, *param_data, &exception); 8169 total_argc, *param_data, &exception);
8164 if (exception) { 8170 if (exception) {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
8330 RUNTIME_FUNCTION(MaybeObject*, Runtime_ConcurrentRecompile) { 8336 RUNTIME_FUNCTION(MaybeObject*, Runtime_ConcurrentRecompile) {
8331 HandleScope handle_scope(isolate); 8337 HandleScope handle_scope(isolate);
8332 ASSERT(args.length() == 1); 8338 ASSERT(args.length() == 1);
8333 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8339 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8334 if (!AllowOptimization(isolate, function)) { 8340 if (!AllowOptimization(isolate, function)) {
8335 function->ReplaceCode(function->shared()->code()); 8341 function->ReplaceCode(function->shared()->code());
8336 return isolate->heap()->undefined_value(); 8342 return isolate->heap()->undefined_value();
8337 } 8343 }
8338 function->shared()->code()->set_profiler_ticks(0); 8344 function->shared()->code()->set_profiler_ticks(0);
8339 ASSERT(FLAG_concurrent_recompilation); 8345 ASSERT(FLAG_concurrent_recompilation);
8340 Compiler::RecompileConcurrent(function); 8346 if (!Compiler::RecompileConcurrent(function)) {
8347 function->ReplaceCode(function->shared()->code());
8348 }
8341 return isolate->heap()->undefined_value(); 8349 return isolate->heap()->undefined_value();
8342 } 8350 }
8343 8351
8344 8352
8345 RUNTIME_FUNCTION(MaybeObject*, Runtime_InstallRecompiledCode) { 8353 RUNTIME_FUNCTION(MaybeObject*, Runtime_InstallRecompiledCode) {
8346 HandleScope handle_scope(isolate); 8354 HandleScope handle_scope(isolate);
8347 ASSERT(args.length() == 1); 8355 ASSERT(args.length() == 1);
8348 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8356 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8349 ASSERT(V8::UseCrankshaft() && FLAG_concurrent_recompilation); 8357 ASSERT(isolate->use_crankshaft() && FLAG_concurrent_recompilation);
8350 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); 8358 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions();
8351 return function->code(); 8359 return function->code();
8352 } 8360 }
8353 8361
8354 8362
8355 class ActivationsFinder : public ThreadVisitor { 8363 class ActivationsFinder : public ThreadVisitor {
8356 public: 8364 public:
8357 Code* code_; 8365 Code* code_;
8358 bool has_code_activations_; 8366 bool has_code_activations_;
8359 8367
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
8499 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8507 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8500 8508
8501 if (!function->IsOptimizable()) return isolate->heap()->undefined_value(); 8509 if (!function->IsOptimizable()) return isolate->heap()->undefined_value();
8502 function->MarkForLazyRecompilation(); 8510 function->MarkForLazyRecompilation();
8503 8511
8504 Code* unoptimized = function->shared()->code(); 8512 Code* unoptimized = function->shared()->code();
8505 if (args.length() == 2 && 8513 if (args.length() == 2 &&
8506 unoptimized->kind() == Code::FUNCTION) { 8514 unoptimized->kind() == Code::FUNCTION) {
8507 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); 8515 CONVERT_ARG_HANDLE_CHECKED(String, type, 1);
8508 if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("osr"))) { 8516 if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("osr"))) {
8509 for (int i = 0; i <= Code::kMaxLoopNestingMarker; i++) { 8517 // Start patching from the currently patched loop nesting level.
8518 int current_level = unoptimized->allow_osr_at_loop_nesting_level();
8519 ASSERT(Deoptimizer::VerifyInterruptCode(
8520 isolate, unoptimized, current_level));
8521 for (int i = current_level + 1; i <= Code::kMaxLoopNestingMarker; i++) {
8510 unoptimized->set_allow_osr_at_loop_nesting_level(i); 8522 unoptimized->set_allow_osr_at_loop_nesting_level(i);
8511 isolate->runtime_profiler()->AttemptOnStackReplacement(*function); 8523 isolate->runtime_profiler()->AttemptOnStackReplacement(*function);
8512 } 8524 }
8513 } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("concurrent"))) { 8525 } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("concurrent"))) {
8514 function->MarkForConcurrentRecompilation(); 8526 function->MarkForConcurrentRecompilation();
8515 } 8527 }
8516 } 8528 }
8517 8529
8518 return isolate->heap()->undefined_value(); 8530 return isolate->heap()->undefined_value();
8519 } 8531 }
8520 8532
8521 8533
8522 RUNTIME_FUNCTION(MaybeObject*, Runtime_NeverOptimizeFunction) { 8534 RUNTIME_FUNCTION(MaybeObject*, Runtime_NeverOptimizeFunction) {
8523 HandleScope scope(isolate); 8535 HandleScope scope(isolate);
8524 ASSERT(args.length() == 1); 8536 ASSERT(args.length() == 1);
8525 CONVERT_ARG_CHECKED(JSFunction, function, 0); 8537 CONVERT_ARG_CHECKED(JSFunction, function, 0);
8526 ASSERT(!function->IsOptimized()); 8538 ASSERT(!function->IsOptimized());
8527 function->shared()->set_optimization_disabled(true); 8539 function->shared()->set_optimization_disabled(true);
8528 return isolate->heap()->undefined_value(); 8540 return isolate->heap()->undefined_value();
8529 } 8541 }
8530 8542
8531 8543
8532 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) { 8544 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) {
8533 HandleScope scope(isolate); 8545 HandleScope scope(isolate);
8534 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); 8546 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2);
8535 if (!V8::UseCrankshaft()) { 8547 if (!isolate->use_crankshaft()) {
8536 return Smi::FromInt(4); // 4 == "never". 8548 return Smi::FromInt(4); // 4 == "never".
8537 } 8549 }
8538 bool sync_with_compiler_thread = true; 8550 bool sync_with_compiler_thread = true;
8539 if (args.length() == 2) { 8551 if (args.length() == 2) {
8540 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1); 8552 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1);
8541 if (sync->IsOneByteEqualTo(STATIC_ASCII_VECTOR("no sync"))) { 8553 if (sync->IsOneByteEqualTo(STATIC_ASCII_VECTOR("no sync"))) {
8542 sync_with_compiler_thread = false; 8554 sync_with_compiler_thread = false;
8543 } 8555 }
8544 } 8556 }
8545 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8557 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
(...skipping 27 matching lines...) Expand all
8573 8585
8574 8586
8575 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { 8587 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) {
8576 HandleScope scope(isolate); 8588 HandleScope scope(isolate);
8577 ASSERT(args.length() == 1); 8589 ASSERT(args.length() == 1);
8578 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8590 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8579 8591
8580 // We're not prepared to handle a function with arguments object. 8592 // We're not prepared to handle a function with arguments object.
8581 ASSERT(!function->shared()->uses_arguments()); 8593 ASSERT(!function->shared()->uses_arguments());
8582 8594
8583 // We have hit a back edge in an unoptimized frame for a function that was
8584 // selected for on-stack replacement. Find the unoptimized code object.
8585 Handle<Code> unoptimized(function->shared()->code(), isolate);
8586 // Keep track of whether we've succeeded in optimizing.
8587 bool succeeded = unoptimized->optimizable();
8588 if (succeeded) {
8589 // If we are trying to do OSR when there are already optimized
8590 // activations of the function, it means (a) the function is directly or
8591 // indirectly recursive and (b) an optimized invocation has been
8592 // deoptimized so that we are currently in an unoptimized activation.
8593 // Check for optimized activations of this function.
8594 JavaScriptFrameIterator it(isolate);
8595 while (succeeded && !it.done()) {
8596 JavaScriptFrame* frame = it.frame();
8597 succeeded = !frame->is_optimized() || frame->function() != *function;
8598 it.Advance();
8599 }
8600 }
8601
8602 BailoutId ast_id = BailoutId::None();
8603 if (succeeded) {
8604 // The top JS function is this one, the PC is somewhere in the
8605 // unoptimized code.
8606 JavaScriptFrameIterator it(isolate);
8607 JavaScriptFrame* frame = it.frame();
8608 ASSERT(frame->function() == *function);
8609 ASSERT(frame->LookupCode() == *unoptimized);
8610 ASSERT(unoptimized->contains(frame->pc()));
8611
8612 // Use linear search of the unoptimized code's back edge table to find
8613 // the AST id matching the PC.
8614 uint32_t target_pc_offset =
8615 static_cast<uint32_t>(frame->pc() - unoptimized->instruction_start());
8616 uint32_t loop_depth = 0;
8617
8618 for (FullCodeGenerator::BackEdgeTableIterator back_edges(*unoptimized);
8619 !back_edges.Done();
8620 back_edges.Next()) {
8621 if (back_edges.pc_offset() == target_pc_offset) {
8622 ast_id = back_edges.ast_id();
8623 loop_depth = back_edges.loop_depth();
8624 break;
8625 }
8626 }
8627 ASSERT(!ast_id.IsNone());
8628
8629 if (FLAG_trace_osr) {
8630 PrintF("[replacing on-stack at AST id %d, loop depth %d in ",
8631 ast_id.ToInt(), loop_depth);
8632 function->PrintName();
8633 PrintF("]\n");
8634 }
8635
8636 // Try to compile the optimized code. A true return value from
8637 // CompileOptimized means that compilation succeeded, not necessarily
8638 // that optimization succeeded.
8639 if (JSFunction::CompileOptimized(function, ast_id, CLEAR_EXCEPTION) &&
8640 function->IsOptimized()) {
8641 DeoptimizationInputData* data = DeoptimizationInputData::cast(
8642 function->code()->deoptimization_data());
8643 if (data->OsrPcOffset()->value() >= 0) {
8644 if (FLAG_trace_osr) {
8645 PrintF("[on-stack replacement offset %d in optimized code]\n",
8646 data->OsrPcOffset()->value());
8647 }
8648 ASSERT(BailoutId(data->OsrAstId()->value()) == ast_id);
8649 } else {
8650 // We may never generate the desired OSR entry if we emit an
8651 // early deoptimize.
8652 succeeded = false;
8653 }
8654 } else {
8655 succeeded = false;
8656 }
8657 }
8658
8659 // Revert to the original interrupt calls in the original unoptimized code.
8660 if (FLAG_trace_osr) {
8661 PrintF("[restoring original interrupt calls in ");
8662 function->PrintName();
8663 PrintF("]\n");
8664 }
8665 Deoptimizer::RevertInterruptCode(isolate, *unoptimized);
8666
8667 // If the optimization attempt succeeded, return the AST id tagged as a 8595 // If the optimization attempt succeeded, return the AST id tagged as a
8668 // smi. This tells the builtin that we need to translate the unoptimized 8596 // smi. This tells the builtin that we need to translate the unoptimized
8669 // frame to an optimized one. 8597 // frame to an optimized one.
8670 if (succeeded) { 8598 BailoutId ast_id =
8599 (FLAG_concurrent_recompilation && FLAG_concurrent_osr)
8600 ? Compiler::CompileForConcurrentOSR(function)
8601 : Compiler::CompileForOnStackReplacement(function);
8602 if (!ast_id.IsNone()) {
8671 ASSERT(function->code()->kind() == Code::OPTIMIZED_FUNCTION); 8603 ASSERT(function->code()->kind() == Code::OPTIMIZED_FUNCTION);
8672 return Smi::FromInt(ast_id.ToInt()); 8604 return Smi::FromInt(ast_id.ToInt());
8673 } else { 8605 } else {
8674 if (function->IsMarkedForLazyRecompilation()) { 8606 if (function->IsMarkedForLazyRecompilation() ||
8607 function->IsMarkedForConcurrentRecompilation()) {
8675 function->ReplaceCode(function->shared()->code()); 8608 function->ReplaceCode(function->shared()->code());
8676 } 8609 }
8677 return Smi::FromInt(-1); 8610 return Smi::FromInt(-1);
8678 } 8611 }
8679 } 8612 }
8680 8613
8681 8614
8682 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAllocationTimeout) { 8615 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAllocationTimeout) {
8683 SealHandleScope shs(isolate); 8616 SealHandleScope shs(isolate);
8684 ASSERT(args.length() == 2); 8617 ASSERT(args.length() == 2);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
8727 for (int i = 0; i < argc; ++i) { 8660 for (int i = 0; i < argc; ++i) {
8728 MaybeObject* maybe = args[1 + i]; 8661 MaybeObject* maybe = args[1 + i];
8729 Object* object; 8662 Object* object;
8730 if (!maybe->To<Object>(&object)) return maybe; 8663 if (!maybe->To<Object>(&object)) return maybe;
8731 argv[i] = Handle<Object>(object, isolate); 8664 argv[i] = Handle<Object>(object, isolate);
8732 } 8665 }
8733 8666
8734 bool threw; 8667 bool threw;
8735 Handle<JSReceiver> hfun(fun); 8668 Handle<JSReceiver> hfun(fun);
8736 Handle<Object> hreceiver(receiver, isolate); 8669 Handle<Object> hreceiver(receiver, isolate);
8737 Handle<Object> result = 8670 Handle<Object> result = Execution::Call(
8738 Execution::Call(hfun, hreceiver, argc, argv, &threw, true); 8671 isolate, hfun, hreceiver, argc, argv, &threw, true);
8739 8672
8740 if (threw) return Failure::Exception(); 8673 if (threw) return Failure::Exception();
8741 return *result; 8674 return *result;
8742 } 8675 }
8743 8676
8744 8677
8745 RUNTIME_FUNCTION(MaybeObject*, Runtime_Apply) { 8678 RUNTIME_FUNCTION(MaybeObject*, Runtime_Apply) {
8746 HandleScope scope(isolate); 8679 HandleScope scope(isolate);
8747 ASSERT(args.length() == 5); 8680 ASSERT(args.length() == 5);
8748 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, fun, 0); 8681 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, fun, 0);
8749 Handle<Object> receiver = args.at<Object>(1); 8682 Handle<Object> receiver = args.at<Object>(1);
8750 CONVERT_ARG_HANDLE_CHECKED(JSObject, arguments, 2); 8683 CONVERT_ARG_HANDLE_CHECKED(JSObject, arguments, 2);
8751 CONVERT_SMI_ARG_CHECKED(offset, 3); 8684 CONVERT_SMI_ARG_CHECKED(offset, 3);
8752 CONVERT_SMI_ARG_CHECKED(argc, 4); 8685 CONVERT_SMI_ARG_CHECKED(argc, 4);
8753 RUNTIME_ASSERT(offset >= 0); 8686 RUNTIME_ASSERT(offset >= 0);
8754 RUNTIME_ASSERT(argc >= 0); 8687 RUNTIME_ASSERT(argc >= 0);
8755 8688
8756 // If there are too many arguments, allocate argv via malloc. 8689 // If there are too many arguments, allocate argv via malloc.
8757 const int argv_small_size = 10; 8690 const int argv_small_size = 10;
8758 Handle<Object> argv_small_buffer[argv_small_size]; 8691 Handle<Object> argv_small_buffer[argv_small_size];
8759 SmartArrayPointer<Handle<Object> > argv_large_buffer; 8692 SmartArrayPointer<Handle<Object> > argv_large_buffer;
8760 Handle<Object>* argv = argv_small_buffer; 8693 Handle<Object>* argv = argv_small_buffer;
8761 if (argc > argv_small_size) { 8694 if (argc > argv_small_size) {
8762 argv = new Handle<Object>[argc]; 8695 argv = new Handle<Object>[argc];
8763 if (argv == NULL) return isolate->StackOverflow(); 8696 if (argv == NULL) return isolate->StackOverflow();
8764 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv); 8697 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv);
8765 } 8698 }
8766 8699
8767 for (int i = 0; i < argc; ++i) { 8700 for (int i = 0; i < argc; ++i) {
8768 argv[i] = Object::GetElement(arguments, offset + i); 8701 argv[i] = Object::GetElement(isolate, arguments, offset + i);
8769 } 8702 }
8770 8703
8771 bool threw; 8704 bool threw;
8772 Handle<Object> result = 8705 Handle<Object> result = Execution::Call(
8773 Execution::Call(fun, receiver, argc, argv, &threw, true); 8706 isolate, fun, receiver, argc, argv, &threw, true);
8774 8707
8775 if (threw) return Failure::Exception(); 8708 if (threw) return Failure::Exception();
8776 return *result; 8709 return *result;
8777 } 8710 }
8778 8711
8779 8712
8780 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionDelegate) { 8713 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionDelegate) {
8781 HandleScope scope(isolate); 8714 HandleScope scope(isolate);
8782 ASSERT(args.length() == 1); 8715 ASSERT(args.length() == 1);
8783 RUNTIME_ASSERT(!args[0]->IsJSFunction()); 8716 RUNTIME_ASSERT(!args[0]->IsJSFunction());
8784 return *Execution::GetFunctionDelegate(args.at<Object>(0)); 8717 return *Execution::GetFunctionDelegate(isolate, args.at<Object>(0));
8785 } 8718 }
8786 8719
8787 8720
8788 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructorDelegate) { 8721 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructorDelegate) {
8789 HandleScope scope(isolate); 8722 HandleScope scope(isolate);
8790 ASSERT(args.length() == 1); 8723 ASSERT(args.length() == 1);
8791 RUNTIME_ASSERT(!args[0]->IsJSFunction()); 8724 RUNTIME_ASSERT(!args[0]->IsJSFunction());
8792 return *Execution::GetConstructorDelegate(args.at<Object>(0)); 8725 return *Execution::GetConstructorDelegate(isolate, args.at<Object>(0));
8793 } 8726 }
8794 8727
8795 8728
8796 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewGlobalContext) { 8729 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewGlobalContext) {
8797 SealHandleScope shs(isolate); 8730 SealHandleScope shs(isolate);
8798 ASSERT(args.length() == 2); 8731 ASSERT(args.length() == 2);
8799 8732
8800 CONVERT_ARG_CHECKED(JSFunction, function, 0); 8733 CONVERT_ARG_CHECKED(JSFunction, function, 0);
8801 CONVERT_ARG_CHECKED(ScopeInfo, scope_info, 1); 8734 CONVERT_ARG_CHECKED(ScopeInfo, scope_info, 1);
8802 Context* result; 8735 Context* result;
(...skipping 28 matching lines...) Expand all
8831 8764
8832 8765
8833 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushWithContext) { 8766 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushWithContext) {
8834 SealHandleScope shs(isolate); 8767 SealHandleScope shs(isolate);
8835 ASSERT(args.length() == 2); 8768 ASSERT(args.length() == 2);
8836 JSReceiver* extension_object; 8769 JSReceiver* extension_object;
8837 if (args[0]->IsJSReceiver()) { 8770 if (args[0]->IsJSReceiver()) {
8838 extension_object = JSReceiver::cast(args[0]); 8771 extension_object = JSReceiver::cast(args[0]);
8839 } else { 8772 } else {
8840 // Convert the object to a proper JavaScript object. 8773 // Convert the object to a proper JavaScript object.
8841 MaybeObject* maybe_js_object = args[0]->ToObject(); 8774 MaybeObject* maybe_js_object = args[0]->ToObject(isolate);
8842 if (!maybe_js_object->To(&extension_object)) { 8775 if (!maybe_js_object->To(&extension_object)) {
8843 if (Failure::cast(maybe_js_object)->IsInternalError()) { 8776 if (Failure::cast(maybe_js_object)->IsInternalError()) {
8844 HandleScope scope(isolate); 8777 HandleScope scope(isolate);
8845 Handle<Object> handle = args.at<Object>(0); 8778 Handle<Object> handle = args.at<Object>(0);
8846 Handle<Object> result = 8779 Handle<Object> result =
8847 isolate->factory()->NewTypeError("with_expression", 8780 isolate->factory()->NewTypeError("with_expression",
8848 HandleVector(&handle, 1)); 8781 HandleVector(&handle, 1));
8849 return isolate->Throw(*result); 8782 return isolate->Throw(*result);
8850 } else { 8783 } else {
8851 return maybe_js_object; 8784 return maybe_js_object;
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after
10145 int fast_length = static_cast<int>(length); 10078 int fast_length = static_cast<int>(length);
10146 ASSERT(fast_length <= elements->length()); 10079 ASSERT(fast_length <= elements->length());
10147 for (int j = 0; j < fast_length; j++) { 10080 for (int j = 0; j < fast_length; j++) {
10148 HandleScope loop_scope(isolate); 10081 HandleScope loop_scope(isolate);
10149 Handle<Object> element_value(elements->get(j), isolate); 10082 Handle<Object> element_value(elements->get(j), isolate);
10150 if (!element_value->IsTheHole()) { 10083 if (!element_value->IsTheHole()) {
10151 visitor->visit(j, element_value); 10084 visitor->visit(j, element_value);
10152 } else if (receiver->HasElement(j)) { 10085 } else if (receiver->HasElement(j)) {
10153 // Call GetElement on receiver, not its prototype, or getters won't 10086 // Call GetElement on receiver, not its prototype, or getters won't
10154 // have the correct receiver. 10087 // have the correct receiver.
10155 element_value = Object::GetElement(receiver, j); 10088 element_value = Object::GetElement(isolate, receiver, j);
10156 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element_value, false); 10089 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element_value, false);
10157 visitor->visit(j, element_value); 10090 visitor->visit(j, element_value);
10158 } 10091 }
10159 } 10092 }
10160 break; 10093 break;
10161 } 10094 }
10162 case FAST_HOLEY_DOUBLE_ELEMENTS: 10095 case FAST_HOLEY_DOUBLE_ELEMENTS:
10163 case FAST_DOUBLE_ELEMENTS: { 10096 case FAST_DOUBLE_ELEMENTS: {
10164 // Run through the elements FixedArray and use HasElement and GetElement 10097 // Run through the elements FixedArray and use HasElement and GetElement
10165 // to check the prototype for missing elements. 10098 // to check the prototype for missing elements.
10166 Handle<FixedDoubleArray> elements( 10099 Handle<FixedDoubleArray> elements(
10167 FixedDoubleArray::cast(receiver->elements())); 10100 FixedDoubleArray::cast(receiver->elements()));
10168 int fast_length = static_cast<int>(length); 10101 int fast_length = static_cast<int>(length);
10169 ASSERT(fast_length <= elements->length()); 10102 ASSERT(fast_length <= elements->length());
10170 for (int j = 0; j < fast_length; j++) { 10103 for (int j = 0; j < fast_length; j++) {
10171 HandleScope loop_scope(isolate); 10104 HandleScope loop_scope(isolate);
10172 if (!elements->is_the_hole(j)) { 10105 if (!elements->is_the_hole(j)) {
10173 double double_value = elements->get_scalar(j); 10106 double double_value = elements->get_scalar(j);
10174 Handle<Object> element_value = 10107 Handle<Object> element_value =
10175 isolate->factory()->NewNumber(double_value); 10108 isolate->factory()->NewNumber(double_value);
10176 visitor->visit(j, element_value); 10109 visitor->visit(j, element_value);
10177 } else if (receiver->HasElement(j)) { 10110 } else if (receiver->HasElement(j)) {
10178 // Call GetElement on receiver, not its prototype, or getters won't 10111 // Call GetElement on receiver, not its prototype, or getters won't
10179 // have the correct receiver. 10112 // have the correct receiver.
10180 Handle<Object> element_value = Object::GetElement(receiver, j); 10113 Handle<Object> element_value =
10114 Object::GetElement(isolate, receiver, j);
10181 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element_value, false); 10115 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element_value, false);
10182 visitor->visit(j, element_value); 10116 visitor->visit(j, element_value);
10183 } 10117 }
10184 } 10118 }
10185 break; 10119 break;
10186 } 10120 }
10187 case DICTIONARY_ELEMENTS: { 10121 case DICTIONARY_ELEMENTS: {
10188 Handle<SeededNumberDictionary> dict(receiver->element_dictionary()); 10122 Handle<SeededNumberDictionary> dict(receiver->element_dictionary());
10189 List<uint32_t> indices(dict->Capacity() / 2); 10123 List<uint32_t> indices(dict->Capacity() / 2);
10190 // Collect all indices in the object and the prototypes less 10124 // Collect all indices in the object and the prototypes less
10191 // than length. This might introduce duplicates in the indices list. 10125 // than length. This might introduce duplicates in the indices list.
10192 CollectElementIndices(receiver, length, &indices); 10126 CollectElementIndices(receiver, length, &indices);
10193 indices.Sort(&compareUInt32); 10127 indices.Sort(&compareUInt32);
10194 int j = 0; 10128 int j = 0;
10195 int n = indices.length(); 10129 int n = indices.length();
10196 while (j < n) { 10130 while (j < n) {
10197 HandleScope loop_scope(isolate); 10131 HandleScope loop_scope(isolate);
10198 uint32_t index = indices[j]; 10132 uint32_t index = indices[j];
10199 Handle<Object> element = Object::GetElement(receiver, index); 10133 Handle<Object> element = Object::GetElement(isolate, receiver, index);
10200 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element, false); 10134 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element, false);
10201 visitor->visit(index, element); 10135 visitor->visit(index, element);
10202 // Skip to next different index (i.e., omit duplicates). 10136 // Skip to next different index (i.e., omit duplicates).
10203 do { 10137 do {
10204 j++; 10138 j++;
10205 } while (j < n && indices[j] == index); 10139 } while (j < n && indices[j] == index);
10206 } 10140 }
10207 break; 10141 break;
10208 } 10142 }
10209 case EXTERNAL_PIXEL_ELEMENTS: { 10143 case EXTERNAL_PIXEL_ELEMENTS: {
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
10569 AccessorComponent component = flag == 0 ? ACCESSOR_GETTER : ACCESSOR_SETTER; 10503 AccessorComponent component = flag == 0 ? ACCESSOR_GETTER : ACCESSOR_SETTER;
10570 if (!receiver->IsJSObject()) return isolate->heap()->undefined_value(); 10504 if (!receiver->IsJSObject()) return isolate->heap()->undefined_value();
10571 return JSObject::cast(receiver)->LookupAccessor(name, component); 10505 return JSObject::cast(receiver)->LookupAccessor(name, component);
10572 } 10506 }
10573 10507
10574 10508
10575 #ifdef ENABLE_DEBUGGER_SUPPORT 10509 #ifdef ENABLE_DEBUGGER_SUPPORT
10576 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugBreak) { 10510 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugBreak) {
10577 SealHandleScope shs(isolate); 10511 SealHandleScope shs(isolate);
10578 ASSERT(args.length() == 0); 10512 ASSERT(args.length() == 0);
10579 return Execution::DebugBreakHelper(); 10513 return Execution::DebugBreakHelper(isolate);
10580 } 10514 }
10581 10515
10582 10516
10583 // Helper functions for wrapping and unwrapping stack frame ids. 10517 // Helper functions for wrapping and unwrapping stack frame ids.
10584 static Smi* WrapFrameId(StackFrame::Id id) { 10518 static Smi* WrapFrameId(StackFrame::Id id) {
10585 ASSERT(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4))); 10519 ASSERT(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4)));
10586 return Smi::FromInt(id >> 2); 10520 return Smi::FromInt(id >> 2);
10587 } 10521 }
10588 10522
10589 10523
(...skipping 1953 matching lines...) Expand 10 before | Expand all | Expand 10 after
12543 } 12477 }
12544 12478
12545 12479
12546 // Prepare for stepping 12480 // Prepare for stepping
12547 // args[0]: break id for checking execution state 12481 // args[0]: break id for checking execution state
12548 // args[1]: step action from the enumeration StepAction 12482 // args[1]: step action from the enumeration StepAction
12549 // args[2]: number of times to perform the step, for step out it is the number 12483 // args[2]: number of times to perform the step, for step out it is the number
12550 // of frames to step down. 12484 // of frames to step down.
12551 RUNTIME_FUNCTION(MaybeObject*, Runtime_PrepareStep) { 12485 RUNTIME_FUNCTION(MaybeObject*, Runtime_PrepareStep) {
12552 HandleScope scope(isolate); 12486 HandleScope scope(isolate);
12553 ASSERT(args.length() == 3); 12487 ASSERT(args.length() == 4);
12554 // Check arguments. 12488 // Check arguments.
12555 Object* check; 12489 Object* check;
12556 { MaybeObject* maybe_check = Runtime_CheckExecutionState( 12490 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
12557 RUNTIME_ARGUMENTS(isolate, args)); 12491 RUNTIME_ARGUMENTS(isolate, args));
12558 if (!maybe_check->ToObject(&check)) return maybe_check; 12492 if (!maybe_check->ToObject(&check)) return maybe_check;
12559 } 12493 }
12560 if (!args[1]->IsNumber() || !args[2]->IsNumber()) { 12494 if (!args[1]->IsNumber() || !args[2]->IsNumber()) {
12561 return isolate->Throw(isolate->heap()->illegal_argument_string()); 12495 return isolate->Throw(isolate->heap()->illegal_argument_string());
12562 } 12496 }
12563 12497
12498 CONVERT_NUMBER_CHECKED(int, wrapped_frame_id, Int32, args[3]);
12499
12500 StackFrame::Id frame_id;
12501 if (wrapped_frame_id == 0) {
12502 frame_id = StackFrame::NO_ID;
12503 } else {
12504 frame_id = UnwrapFrameId(wrapped_frame_id);
12505 }
12506
12564 // Get the step action and check validity. 12507 // Get the step action and check validity.
12565 StepAction step_action = static_cast<StepAction>(NumberToInt32(args[1])); 12508 StepAction step_action = static_cast<StepAction>(NumberToInt32(args[1]));
12566 if (step_action != StepIn && 12509 if (step_action != StepIn &&
12567 step_action != StepNext && 12510 step_action != StepNext &&
12568 step_action != StepOut && 12511 step_action != StepOut &&
12569 step_action != StepInMin && 12512 step_action != StepInMin &&
12570 step_action != StepMin) { 12513 step_action != StepMin) {
12571 return isolate->Throw(isolate->heap()->illegal_argument_string()); 12514 return isolate->Throw(isolate->heap()->illegal_argument_string());
12572 } 12515 }
12573 12516
12517 if (frame_id != StackFrame::NO_ID && step_action != StepNext &&
12518 step_action != StepMin && step_action != StepOut) {
12519 return isolate->ThrowIllegalOperation();
12520 }
12521
12574 // Get the number of steps. 12522 // Get the number of steps.
12575 int step_count = NumberToInt32(args[2]); 12523 int step_count = NumberToInt32(args[2]);
12576 if (step_count < 1) { 12524 if (step_count < 1) {
12577 return isolate->Throw(isolate->heap()->illegal_argument_string()); 12525 return isolate->Throw(isolate->heap()->illegal_argument_string());
12578 } 12526 }
12579 12527
12580 // Clear all current stepping setup. 12528 // Clear all current stepping setup.
12581 isolate->debug()->ClearStepping(); 12529 isolate->debug()->ClearStepping();
12582 12530
12583 // Prepare step. 12531 // Prepare step.
12584 isolate->debug()->PrepareStep(static_cast<StepAction>(step_action), 12532 isolate->debug()->PrepareStep(static_cast<StepAction>(step_action),
12585 step_count); 12533 step_count,
12534 frame_id);
12586 return isolate->heap()->undefined_value(); 12535 return isolate->heap()->undefined_value();
12587 } 12536 }
12588 12537
12589 12538
12590 // Clear all stepping set by PrepareStep. 12539 // Clear all stepping set by PrepareStep.
12591 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearStepping) { 12540 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearStepping) {
12592 HandleScope scope(isolate); 12541 HandleScope scope(isolate);
12593 ASSERT(args.length() == 0); 12542 ASSERT(args.length() == 0);
12594 isolate->debug()->ClearStepping(); 12543 isolate->debug()->ClearStepping();
12595 return isolate->heap()->undefined_value(); 12544 return isolate->heap()->undefined_value();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
12641 CLASSIC_MODE, 12590 CLASSIC_MODE,
12642 NO_PARSE_RESTRICTION, 12591 NO_PARSE_RESTRICTION,
12643 RelocInfo::kNoPosition); 12592 RelocInfo::kNoPosition);
12644 RETURN_IF_EMPTY_HANDLE(isolate, shared); 12593 RETURN_IF_EMPTY_HANDLE(isolate, shared);
12645 12594
12646 Handle<JSFunction> eval_fun = 12595 Handle<JSFunction> eval_fun =
12647 isolate->factory()->NewFunctionFromSharedFunctionInfo( 12596 isolate->factory()->NewFunctionFromSharedFunctionInfo(
12648 shared, context, NOT_TENURED); 12597 shared, context, NOT_TENURED);
12649 bool pending_exception; 12598 bool pending_exception;
12650 Handle<Object> result = Execution::Call( 12599 Handle<Object> result = Execution::Call(
12651 eval_fun, receiver, 0, NULL, &pending_exception); 12600 isolate, eval_fun, receiver, 0, NULL, &pending_exception);
12652 12601
12653 if (pending_exception) return Failure::Exception(); 12602 if (pending_exception) return Failure::Exception();
12654 12603
12655 // Skip the global proxy as it has no properties and always delegates to the 12604 // Skip the global proxy as it has no properties and always delegates to the
12656 // real global object. 12605 // real global object.
12657 if (result->IsJSGlobalProxy()) { 12606 if (result->IsJSGlobalProxy()) {
12658 result = Handle<JSObject>(JSObject::cast(result->GetPrototype(isolate))); 12607 result = Handle<JSObject>(JSObject::cast(result->GetPrototype(isolate)));
12659 } 12608 }
12660 12609
12661 // Clear the oneshot breakpoints so that the debugger does not step further. 12610 // Clear the oneshot breakpoints so that the debugger does not step further.
(...skipping 18 matching lines...) Expand all
12680 RUNTIME_ARGUMENTS(isolate, args)); 12629 RUNTIME_ARGUMENTS(isolate, args));
12681 if (!maybe_result->ToObject(&check_result)) return maybe_result; 12630 if (!maybe_result->ToObject(&check_result)) return maybe_result;
12682 } 12631 }
12683 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); 12632 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1);
12684 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); 12633 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]);
12685 CONVERT_ARG_HANDLE_CHECKED(String, source, 3); 12634 CONVERT_ARG_HANDLE_CHECKED(String, source, 3);
12686 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4); 12635 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4);
12687 Handle<Object> context_extension(args[5], isolate); 12636 Handle<Object> context_extension(args[5], isolate);
12688 12637
12689 // Handle the processing of break. 12638 // Handle the processing of break.
12690 DisableBreak disable_break_save(disable_break); 12639 DisableBreak disable_break_save(isolate, disable_break);
12691 12640
12692 // Get the frame where the debugging is performed. 12641 // Get the frame where the debugging is performed.
12693 StackFrame::Id id = UnwrapFrameId(wrapped_id); 12642 StackFrame::Id id = UnwrapFrameId(wrapped_id);
12694 JavaScriptFrameIterator it(isolate, id); 12643 JavaScriptFrameIterator it(isolate, id);
12695 JavaScriptFrame* frame = it.frame(); 12644 JavaScriptFrame* frame = it.frame();
12696 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); 12645 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate);
12697 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); 12646 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction()));
12698 12647
12699 // Traverse the saved contexts chain to find the active context for the 12648 // Traverse the saved contexts chain to find the active context for the
12700 // selected frame. 12649 // selected frame.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
12747 Object* check_result; 12696 Object* check_result;
12748 { MaybeObject* maybe_result = Runtime_CheckExecutionState( 12697 { MaybeObject* maybe_result = Runtime_CheckExecutionState(
12749 RUNTIME_ARGUMENTS(isolate, args)); 12698 RUNTIME_ARGUMENTS(isolate, args));
12750 if (!maybe_result->ToObject(&check_result)) return maybe_result; 12699 if (!maybe_result->ToObject(&check_result)) return maybe_result;
12751 } 12700 }
12752 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); 12701 CONVERT_ARG_HANDLE_CHECKED(String, source, 1);
12753 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2); 12702 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2);
12754 Handle<Object> context_extension(args[3], isolate); 12703 Handle<Object> context_extension(args[3], isolate);
12755 12704
12756 // Handle the processing of break. 12705 // Handle the processing of break.
12757 DisableBreak disable_break_save(disable_break); 12706 DisableBreak disable_break_save(isolate, disable_break);
12758 12707
12759 // Enter the top context from before the debugger was invoked. 12708 // Enter the top context from before the debugger was invoked.
12760 SaveContext save(isolate); 12709 SaveContext save(isolate);
12761 SaveContext* top = &save; 12710 SaveContext* top = &save;
12762 while (top != NULL && *top->context() == *isolate->debug()->debug_context()) { 12711 while (top != NULL && *top->context() == *isolate->debug()->debug_context()) {
12763 top = top->prev(); 12712 top = top->prev();
12764 } 12713 }
12765 if (top != NULL) { 12714 if (top != NULL) {
12766 isolate->set_context(*top->context()); 12715 isolate->set_context(*top->context());
12767 } 12716 }
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
13412 RUNTIME_FUNCTION(MaybeObject*, Runtime_ExecuteInDebugContext) { 13361 RUNTIME_FUNCTION(MaybeObject*, Runtime_ExecuteInDebugContext) {
13413 HandleScope scope(isolate); 13362 HandleScope scope(isolate);
13414 ASSERT(args.length() == 2); 13363 ASSERT(args.length() == 2);
13415 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 13364 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
13416 CONVERT_BOOLEAN_ARG_CHECKED(without_debugger, 1); 13365 CONVERT_BOOLEAN_ARG_CHECKED(without_debugger, 1);
13417 13366
13418 Handle<Object> result; 13367 Handle<Object> result;
13419 bool pending_exception; 13368 bool pending_exception;
13420 { 13369 {
13421 if (without_debugger) { 13370 if (without_debugger) {
13422 result = Execution::Call(function, isolate->global_object(), 0, NULL, 13371 result = Execution::Call(isolate,
13372 function,
13373 isolate->global_object(),
13374 0,
13375 NULL,
13423 &pending_exception); 13376 &pending_exception);
13424 } else { 13377 } else {
13425 EnterDebugger enter_debugger; 13378 EnterDebugger enter_debugger(isolate);
13426 result = Execution::Call(function, isolate->global_object(), 0, NULL, 13379 result = Execution::Call(isolate,
13380 function,
13381 isolate->global_object(),
13382 0,
13383 NULL,
13427 &pending_exception); 13384 &pending_exception);
13428 } 13385 }
13429 } 13386 }
13430 if (!pending_exception) { 13387 if (!pending_exception) {
13431 return *result; 13388 return *result;
13432 } else { 13389 } else {
13433 return Failure::Exception(); 13390 return Failure::Exception();
13434 } 13391 }
13435 } 13392 }
13436 13393
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
13577 13534
13578 CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0); 13535 CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0);
13579 13536
13580 uint32_t length = static_cast<uint32_t>(input->length()->Number()); 13537 uint32_t length = static_cast<uint32_t>(input->length()->Number());
13581 Handle<FixedArray> output = isolate->factory()->NewFixedArray(length); 13538 Handle<FixedArray> output = isolate->factory()->NewFixedArray(length);
13582 Handle<Name> maximized = 13539 Handle<Name> maximized =
13583 isolate->factory()->NewStringFromAscii(CStrVector("maximized")); 13540 isolate->factory()->NewStringFromAscii(CStrVector("maximized"));
13584 Handle<Name> base = 13541 Handle<Name> base =
13585 isolate->factory()->NewStringFromAscii(CStrVector("base")); 13542 isolate->factory()->NewStringFromAscii(CStrVector("base"));
13586 for (unsigned int i = 0; i < length; ++i) { 13543 for (unsigned int i = 0; i < length; ++i) {
13587 MaybeObject* maybe_string = input->GetElement(i); 13544 MaybeObject* maybe_string = input->GetElement(isolate, i);
13588 Object* locale_id; 13545 Object* locale_id;
13589 if (!maybe_string->ToObject(&locale_id) || !locale_id->IsString()) { 13546 if (!maybe_string->ToObject(&locale_id) || !locale_id->IsString()) {
13590 return isolate->Throw(isolate->heap()->illegal_argument_string()); 13547 return isolate->Throw(isolate->heap()->illegal_argument_string());
13591 } 13548 }
13592 13549
13593 v8::String::Utf8Value utf8_locale_id( 13550 v8::String::Utf8Value utf8_locale_id(
13594 v8::Utils::ToLocal(Handle<String>(String::cast(locale_id)))); 13551 v8::Utils::ToLocal(Handle<String>(String::cast(locale_id))));
13595 13552
13596 UErrorCode error = U_ZERO_ERROR; 13553 UErrorCode error = U_ZERO_ERROR;
13597 13554
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
13708 13665
13709 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalDateFormat) { 13666 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalDateFormat) {
13710 HandleScope scope(isolate); 13667 HandleScope scope(isolate);
13711 13668
13712 ASSERT(args.length() == 2); 13669 ASSERT(args.length() == 2);
13713 13670
13714 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); 13671 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0);
13715 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1); 13672 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1);
13716 13673
13717 bool has_pending_exception = false; 13674 bool has_pending_exception = false;
13718 Handle<Object> value = Execution::ToNumber(date, &has_pending_exception); 13675 Handle<Object> value =
13676 Execution::ToNumber(isolate, date, &has_pending_exception);
13719 if (has_pending_exception) { 13677 if (has_pending_exception) {
13720 ASSERT(isolate->has_pending_exception()); 13678 ASSERT(isolate->has_pending_exception());
13721 return Failure::Exception(); 13679 return Failure::Exception();
13722 } 13680 }
13723 13681
13724 icu::SimpleDateFormat* date_format = 13682 icu::SimpleDateFormat* date_format =
13725 DateFormat::UnpackDateFormat(isolate, date_format_holder); 13683 DateFormat::UnpackDateFormat(isolate, date_format_holder);
13726 if (!date_format) return isolate->ThrowIllegalOperation(); 13684 if (!date_format) return isolate->ThrowIllegalOperation();
13727 13685
13728 icu::UnicodeString result; 13686 icu::UnicodeString result;
(...skipping 19 matching lines...) Expand all
13748 icu::SimpleDateFormat* date_format = 13706 icu::SimpleDateFormat* date_format =
13749 DateFormat::UnpackDateFormat(isolate, date_format_holder); 13707 DateFormat::UnpackDateFormat(isolate, date_format_holder);
13750 if (!date_format) return isolate->ThrowIllegalOperation(); 13708 if (!date_format) return isolate->ThrowIllegalOperation();
13751 13709
13752 UErrorCode status = U_ZERO_ERROR; 13710 UErrorCode status = U_ZERO_ERROR;
13753 UDate date = date_format->parse(u_date, status); 13711 UDate date = date_format->parse(u_date, status);
13754 if (U_FAILURE(status)) return isolate->heap()->undefined_value(); 13712 if (U_FAILURE(status)) return isolate->heap()->undefined_value();
13755 13713
13756 bool has_pending_exception = false; 13714 bool has_pending_exception = false;
13757 Handle<JSDate> result = Handle<JSDate>::cast( 13715 Handle<JSDate> result = Handle<JSDate>::cast(
13758 Execution::NewDate(static_cast<double>(date), &has_pending_exception)); 13716 Execution::NewDate(
13717 isolate, static_cast<double>(date), &has_pending_exception));
13759 if (has_pending_exception) { 13718 if (has_pending_exception) {
13760 ASSERT(isolate->has_pending_exception()); 13719 ASSERT(isolate->has_pending_exception());
13761 return Failure::Exception(); 13720 return Failure::Exception();
13762 } 13721 }
13763 return *result; 13722 return *result;
13764 } 13723 }
13765 13724
13766 13725
13767 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateNumberFormat) { 13726 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateNumberFormat) {
13768 HandleScope scope(isolate); 13727 HandleScope scope(isolate);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
13810 13769
13811 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberFormat) { 13770 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberFormat) {
13812 HandleScope scope(isolate); 13771 HandleScope scope(isolate);
13813 13772
13814 ASSERT(args.length() == 2); 13773 ASSERT(args.length() == 2);
13815 13774
13816 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); 13775 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0);
13817 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1); 13776 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1);
13818 13777
13819 bool has_pending_exception = false; 13778 bool has_pending_exception = false;
13820 Handle<Object> value = Execution::ToNumber(number, &has_pending_exception); 13779 Handle<Object> value = Execution::ToNumber(
13780 isolate, number, &has_pending_exception);
13821 if (has_pending_exception) { 13781 if (has_pending_exception) {
13822 ASSERT(isolate->has_pending_exception()); 13782 ASSERT(isolate->has_pending_exception());
13823 return Failure::Exception(); 13783 return Failure::Exception();
13824 } 13784 }
13825 13785
13826 icu::DecimalFormat* number_format = 13786 icu::DecimalFormat* number_format =
13827 NumberFormat::UnpackNumberFormat(isolate, number_format_holder); 13787 NumberFormat::UnpackNumberFormat(isolate, number_format_holder);
13828 if (!number_format) return isolate->ThrowIllegalOperation(); 13788 if (!number_format) return isolate->ThrowIllegalOperation();
13829 13789
13830 icu::UnicodeString result; 13790 icu::UnicodeString result;
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
14280 Handle<Object> value; 14240 Handle<Object> value;
14281 { 14241 {
14282 Handle<JSFunction> factory(JSFunction::cast( 14242 Handle<JSFunction> factory(JSFunction::cast(
14283 cache_handle->get(JSFunctionResultCache::kFactoryIndex))); 14243 cache_handle->get(JSFunctionResultCache::kFactoryIndex)));
14284 // TODO(antonm): consider passing a receiver when constructing a cache. 14244 // TODO(antonm): consider passing a receiver when constructing a cache.
14285 Handle<Object> receiver(isolate->native_context()->global_object(), 14245 Handle<Object> receiver(isolate->native_context()->global_object(),
14286 isolate); 14246 isolate);
14287 // This handle is nor shared, nor used later, so it's safe. 14247 // This handle is nor shared, nor used later, so it's safe.
14288 Handle<Object> argv[] = { key_handle }; 14248 Handle<Object> argv[] = { key_handle };
14289 bool pending_exception; 14249 bool pending_exception;
14290 value = Execution::Call(factory, 14250 value = Execution::Call(isolate,
14251 factory,
14291 receiver, 14252 receiver,
14292 ARRAY_SIZE(argv), 14253 ARRAY_SIZE(argv),
14293 argv, 14254 argv,
14294 &pending_exception); 14255 &pending_exception);
14295 if (pending_exception) return Failure::Exception(); 14256 if (pending_exception) return Failure::Exception();
14296 } 14257 }
14297 14258
14298 #ifdef VERIFY_HEAP 14259 #ifdef VERIFY_HEAP
14299 if (FLAG_verify_heap) { 14260 if (FLAG_verify_heap) {
14300 cache_handle->JSFunctionResultCacheVerify(); 14261 cache_handle->JSFunctionResultCacheVerify();
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
14649 14610
14650 static const Runtime::Function kIntrinsicFunctions[] = { 14611 static const Runtime::Function kIntrinsicFunctions[] = {
14651 RUNTIME_FUNCTION_LIST(F) 14612 RUNTIME_FUNCTION_LIST(F)
14652 INLINE_FUNCTION_LIST(I) 14613 INLINE_FUNCTION_LIST(I)
14653 INLINE_RUNTIME_FUNCTION_LIST(I) 14614 INLINE_RUNTIME_FUNCTION_LIST(I)
14654 }; 14615 };
14655 14616
14656 14617
14657 MaybeObject* Runtime::InitializeIntrinsicFunctionNames(Heap* heap, 14618 MaybeObject* Runtime::InitializeIntrinsicFunctionNames(Heap* heap,
14658 Object* dictionary) { 14619 Object* dictionary) {
14659 ASSERT(Isolate::Current()->heap() == heap);
14660 ASSERT(dictionary != NULL); 14620 ASSERT(dictionary != NULL);
14661 ASSERT(NameDictionary::cast(dictionary)->NumberOfElements() == 0); 14621 ASSERT(NameDictionary::cast(dictionary)->NumberOfElements() == 0);
14662 for (int i = 0; i < kNumFunctions; ++i) { 14622 for (int i = 0; i < kNumFunctions; ++i) {
14663 Object* name_string; 14623 Object* name_string;
14664 { MaybeObject* maybe_name_string = 14624 { MaybeObject* maybe_name_string =
14665 heap->InternalizeUtf8String(kIntrinsicFunctions[i].name); 14625 heap->InternalizeUtf8String(kIntrinsicFunctions[i].name);
14666 if (!maybe_name_string->ToObject(&name_string)) return maybe_name_string; 14626 if (!maybe_name_string->ToObject(&name_string)) return maybe_name_string;
14667 } 14627 }
14668 NameDictionary* name_dictionary = NameDictionary::cast(dictionary); 14628 NameDictionary* name_dictionary = NameDictionary::cast(dictionary);
14669 { MaybeObject* maybe_dictionary = name_dictionary->Add( 14629 { MaybeObject* maybe_dictionary = name_dictionary->Add(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
14714 // Handle last resort GC and make sure to allow future allocations 14674 // Handle last resort GC and make sure to allow future allocations
14715 // to grow the heap without causing GCs (if possible). 14675 // to grow the heap without causing GCs (if possible).
14716 isolate->counters()->gc_last_resort_from_js()->Increment(); 14676 isolate->counters()->gc_last_resort_from_js()->Increment();
14717 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14677 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14718 "Runtime::PerformGC"); 14678 "Runtime::PerformGC");
14719 } 14679 }
14720 } 14680 }
14721 14681
14722 14682
14723 } } // namespace v8::internal 14683 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/runtime-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698