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

Side by Side Diff: src/runtime.cc

Issue 23757017: remove Isolate::Current from most files starting with 'o' through 'r' (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
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/parser.cc ('k') | test/cctest/test-api.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 4756 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;
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after
5897 Handle<Object> converted = 5897 Handle<Object> converted =
5898 Execution::ToString(isolate, args.at<Object>(0), &exception); 5898 Execution::ToString(isolate, args.at<Object>(0), &exception);
5899 if (exception) return Failure::Exception(); 5899 if (exception) return Failure::Exception();
5900 Handle<String> key = Handle<String>::cast(converted); 5900 Handle<String> key = Handle<String>::cast(converted);
5901 5901
5902 // Try to convert the string key into an array index. 5902 // Try to convert the string key into an array index.
5903 if (key->AsArrayIndex(&index)) { 5903 if (key->AsArrayIndex(&index)) {
5904 if (index < n) { 5904 if (index < n) {
5905 return frame->GetParameter(index); 5905 return frame->GetParameter(index);
5906 } else { 5906 } else {
5907 return isolate->initial_object_prototype()->GetElement(index); 5907 return isolate->initial_object_prototype()->GetElement(isolate, index);
5908 } 5908 }
5909 } 5909 }
5910 5910
5911 // Handle special arguments properties. 5911 // Handle special arguments properties.
5912 if (key->Equals(isolate->heap()->length_string())) return Smi::FromInt(n); 5912 if (key->Equals(isolate->heap()->length_string())) return Smi::FromInt(n);
5913 if (key->Equals(isolate->heap()->callee_string())) { 5913 if (key->Equals(isolate->heap()->callee_string())) {
5914 JSFunction* function = frame->function(); 5914 JSFunction* function = frame->function();
5915 if (!function->shared()->is_classic_mode()) { 5915 if (!function->shared()->is_classic_mode()) {
5916 return isolate->Throw(*isolate->factory()->NewTypeError( 5916 return isolate->Throw(*isolate->factory()->NewTypeError(
5917 "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
6672 #endif 6672 #endif
6673 6673
6674 return *isolate->factory()->NewJSArrayWithElements(elements); 6674 return *isolate->factory()->NewJSArrayWithElements(elements);
6675 } 6675 }
6676 6676
6677 6677
6678 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStringWrapper) { 6678 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStringWrapper) {
6679 SealHandleScope shs(isolate); 6679 SealHandleScope shs(isolate);
6680 ASSERT(args.length() == 1); 6680 ASSERT(args.length() == 1);
6681 CONVERT_ARG_CHECKED(String, value, 0); 6681 CONVERT_ARG_CHECKED(String, value, 0);
6682 return value->ToObject(); 6682 return value->ToObject(isolate);
6683 } 6683 }
6684 6684
6685 6685
6686 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { 6686 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) {
6687 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; 6687 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth];
6688 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);
6689 return char_length == 0; 6689 return char_length == 0;
6690 } 6690 }
6691 6691
6692 6692
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
7521 r = CompareChars(x_chars.start(), y_chars.start(), prefix_length); 7521 r = CompareChars(x_chars.start(), y_chars.start(), prefix_length);
7522 } 7522 }
7523 } 7523 }
7524 Object* result; 7524 Object* result;
7525 if (r == 0) { 7525 if (r == 0) {
7526 result = equal_prefix_result; 7526 result = equal_prefix_result;
7527 } else { 7527 } else {
7528 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); 7528 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER);
7529 } 7529 }
7530 ASSERT(result == 7530 ASSERT(result ==
7531 StringCharacterStreamCompare(Isolate::Current()->runtime_state(), x, y)); 7531 StringCharacterStreamCompare(x->GetIsolate()->runtime_state(), x, y));
7532 return result; 7532 return result;
7533 } 7533 }
7534 7534
7535 7535
7536 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCompare) { 7536 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCompare) {
7537 SealHandleScope shs(isolate); 7537 SealHandleScope shs(isolate);
7538 ASSERT(args.length() == 2); 7538 ASSERT(args.length() == 2);
7539 7539
7540 CONVERT_ARG_CHECKED(String, x, 0); 7540 CONVERT_ARG_CHECKED(String, x, 0);
7541 CONVERT_ARG_CHECKED(String, y, 1); 7541 CONVERT_ARG_CHECKED(String, y, 1);
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
8764 Handle<Object> argv_small_buffer[argv_small_size]; 8764 Handle<Object> argv_small_buffer[argv_small_size];
8765 SmartArrayPointer<Handle<Object> > argv_large_buffer; 8765 SmartArrayPointer<Handle<Object> > argv_large_buffer;
8766 Handle<Object>* argv = argv_small_buffer; 8766 Handle<Object>* argv = argv_small_buffer;
8767 if (argc > argv_small_size) { 8767 if (argc > argv_small_size) {
8768 argv = new Handle<Object>[argc]; 8768 argv = new Handle<Object>[argc];
8769 if (argv == NULL) return isolate->StackOverflow(); 8769 if (argv == NULL) return isolate->StackOverflow();
8770 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv); 8770 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv);
8771 } 8771 }
8772 8772
8773 for (int i = 0; i < argc; ++i) { 8773 for (int i = 0; i < argc; ++i) {
8774 argv[i] = Object::GetElement(arguments, offset + i); 8774 argv[i] = Object::GetElement(isolate, arguments, offset + i);
8775 } 8775 }
8776 8776
8777 bool threw; 8777 bool threw;
8778 Handle<Object> result = 8778 Handle<Object> result =
8779 Execution::Call(fun, receiver, argc, argv, &threw, true); 8779 Execution::Call(fun, receiver, argc, argv, &threw, true);
8780 8780
8781 if (threw) return Failure::Exception(); 8781 if (threw) return Failure::Exception();
8782 return *result; 8782 return *result;
8783 } 8783 }
8784 8784
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
8837 8837
8838 8838
8839 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushWithContext) { 8839 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushWithContext) {
8840 SealHandleScope shs(isolate); 8840 SealHandleScope shs(isolate);
8841 ASSERT(args.length() == 2); 8841 ASSERT(args.length() == 2);
8842 JSReceiver* extension_object; 8842 JSReceiver* extension_object;
8843 if (args[0]->IsJSReceiver()) { 8843 if (args[0]->IsJSReceiver()) {
8844 extension_object = JSReceiver::cast(args[0]); 8844 extension_object = JSReceiver::cast(args[0]);
8845 } else { 8845 } else {
8846 // Convert the object to a proper JavaScript object. 8846 // Convert the object to a proper JavaScript object.
8847 MaybeObject* maybe_js_object = args[0]->ToObject(); 8847 MaybeObject* maybe_js_object = args[0]->ToObject(isolate);
8848 if (!maybe_js_object->To(&extension_object)) { 8848 if (!maybe_js_object->To(&extension_object)) {
8849 if (Failure::cast(maybe_js_object)->IsInternalError()) { 8849 if (Failure::cast(maybe_js_object)->IsInternalError()) {
8850 HandleScope scope(isolate); 8850 HandleScope scope(isolate);
8851 Handle<Object> handle = args.at<Object>(0); 8851 Handle<Object> handle = args.at<Object>(0);
8852 Handle<Object> result = 8852 Handle<Object> result =
8853 isolate->factory()->NewTypeError("with_expression", 8853 isolate->factory()->NewTypeError("with_expression",
8854 HandleVector(&handle, 1)); 8854 HandleVector(&handle, 1));
8855 return isolate->Throw(*result); 8855 return isolate->Throw(*result);
8856 } else { 8856 } else {
8857 return maybe_js_object; 8857 return maybe_js_object;
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after
10151 int fast_length = static_cast<int>(length); 10151 int fast_length = static_cast<int>(length);
10152 ASSERT(fast_length <= elements->length()); 10152 ASSERT(fast_length <= elements->length());
10153 for (int j = 0; j < fast_length; j++) { 10153 for (int j = 0; j < fast_length; j++) {
10154 HandleScope loop_scope(isolate); 10154 HandleScope loop_scope(isolate);
10155 Handle<Object> element_value(elements->get(j), isolate); 10155 Handle<Object> element_value(elements->get(j), isolate);
10156 if (!element_value->IsTheHole()) { 10156 if (!element_value->IsTheHole()) {
10157 visitor->visit(j, element_value); 10157 visitor->visit(j, element_value);
10158 } else if (receiver->HasElement(j)) { 10158 } else if (receiver->HasElement(j)) {
10159 // Call GetElement on receiver, not its prototype, or getters won't 10159 // Call GetElement on receiver, not its prototype, or getters won't
10160 // have the correct receiver. 10160 // have the correct receiver.
10161 element_value = Object::GetElement(receiver, j); 10161 element_value = Object::GetElement(isolate, receiver, j);
10162 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element_value, false); 10162 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element_value, false);
10163 visitor->visit(j, element_value); 10163 visitor->visit(j, element_value);
10164 } 10164 }
10165 } 10165 }
10166 break; 10166 break;
10167 } 10167 }
10168 case FAST_HOLEY_DOUBLE_ELEMENTS: 10168 case FAST_HOLEY_DOUBLE_ELEMENTS:
10169 case FAST_DOUBLE_ELEMENTS: { 10169 case FAST_DOUBLE_ELEMENTS: {
10170 // Run through the elements FixedArray and use HasElement and GetElement 10170 // Run through the elements FixedArray and use HasElement and GetElement
10171 // to check the prototype for missing elements. 10171 // to check the prototype for missing elements.
10172 Handle<FixedDoubleArray> elements( 10172 Handle<FixedDoubleArray> elements(
10173 FixedDoubleArray::cast(receiver->elements())); 10173 FixedDoubleArray::cast(receiver->elements()));
10174 int fast_length = static_cast<int>(length); 10174 int fast_length = static_cast<int>(length);
10175 ASSERT(fast_length <= elements->length()); 10175 ASSERT(fast_length <= elements->length());
10176 for (int j = 0; j < fast_length; j++) { 10176 for (int j = 0; j < fast_length; j++) {
10177 HandleScope loop_scope(isolate); 10177 HandleScope loop_scope(isolate);
10178 if (!elements->is_the_hole(j)) { 10178 if (!elements->is_the_hole(j)) {
10179 double double_value = elements->get_scalar(j); 10179 double double_value = elements->get_scalar(j);
10180 Handle<Object> element_value = 10180 Handle<Object> element_value =
10181 isolate->factory()->NewNumber(double_value); 10181 isolate->factory()->NewNumber(double_value);
10182 visitor->visit(j, element_value); 10182 visitor->visit(j, element_value);
10183 } else if (receiver->HasElement(j)) { 10183 } else if (receiver->HasElement(j)) {
10184 // Call GetElement on receiver, not its prototype, or getters won't 10184 // Call GetElement on receiver, not its prototype, or getters won't
10185 // have the correct receiver. 10185 // have the correct receiver.
10186 Handle<Object> element_value = Object::GetElement(receiver, j); 10186 Handle<Object> element_value =
10187 Object::GetElement(isolate, receiver, j);
10187 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element_value, false); 10188 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element_value, false);
10188 visitor->visit(j, element_value); 10189 visitor->visit(j, element_value);
10189 } 10190 }
10190 } 10191 }
10191 break; 10192 break;
10192 } 10193 }
10193 case DICTIONARY_ELEMENTS: { 10194 case DICTIONARY_ELEMENTS: {
10194 Handle<SeededNumberDictionary> dict(receiver->element_dictionary()); 10195 Handle<SeededNumberDictionary> dict(receiver->element_dictionary());
10195 List<uint32_t> indices(dict->Capacity() / 2); 10196 List<uint32_t> indices(dict->Capacity() / 2);
10196 // Collect all indices in the object and the prototypes less 10197 // Collect all indices in the object and the prototypes less
10197 // than length. This might introduce duplicates in the indices list. 10198 // than length. This might introduce duplicates in the indices list.
10198 CollectElementIndices(receiver, length, &indices); 10199 CollectElementIndices(receiver, length, &indices);
10199 indices.Sort(&compareUInt32); 10200 indices.Sort(&compareUInt32);
10200 int j = 0; 10201 int j = 0;
10201 int n = indices.length(); 10202 int n = indices.length();
10202 while (j < n) { 10203 while (j < n) {
10203 HandleScope loop_scope(isolate); 10204 HandleScope loop_scope(isolate);
10204 uint32_t index = indices[j]; 10205 uint32_t index = indices[j];
10205 Handle<Object> element = Object::GetElement(receiver, index); 10206 Handle<Object> element = Object::GetElement(isolate, receiver, index);
10206 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element, false); 10207 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element, false);
10207 visitor->visit(index, element); 10208 visitor->visit(index, element);
10208 // Skip to next different index (i.e., omit duplicates). 10209 // Skip to next different index (i.e., omit duplicates).
10209 do { 10210 do {
10210 j++; 10211 j++;
10211 } while (j < n && indices[j] == index); 10212 } while (j < n && indices[j] == index);
10212 } 10213 }
10213 break; 10214 break;
10214 } 10215 }
10215 case EXTERNAL_PIXEL_ELEMENTS: { 10216 case EXTERNAL_PIXEL_ELEMENTS: {
(...skipping 3367 matching lines...) Expand 10 before | Expand all | Expand 10 after
13583 13584
13584 CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0); 13585 CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0);
13585 13586
13586 uint32_t length = static_cast<uint32_t>(input->length()->Number()); 13587 uint32_t length = static_cast<uint32_t>(input->length()->Number());
13587 Handle<FixedArray> output = isolate->factory()->NewFixedArray(length); 13588 Handle<FixedArray> output = isolate->factory()->NewFixedArray(length);
13588 Handle<Name> maximized = 13589 Handle<Name> maximized =
13589 isolate->factory()->NewStringFromAscii(CStrVector("maximized")); 13590 isolate->factory()->NewStringFromAscii(CStrVector("maximized"));
13590 Handle<Name> base = 13591 Handle<Name> base =
13591 isolate->factory()->NewStringFromAscii(CStrVector("base")); 13592 isolate->factory()->NewStringFromAscii(CStrVector("base"));
13592 for (unsigned int i = 0; i < length; ++i) { 13593 for (unsigned int i = 0; i < length; ++i) {
13593 MaybeObject* maybe_string = input->GetElement(i); 13594 MaybeObject* maybe_string = input->GetElement(isolate, i);
13594 Object* locale_id; 13595 Object* locale_id;
13595 if (!maybe_string->ToObject(&locale_id) || !locale_id->IsString()) { 13596 if (!maybe_string->ToObject(&locale_id) || !locale_id->IsString()) {
13596 return isolate->Throw(isolate->heap()->illegal_argument_string()); 13597 return isolate->Throw(isolate->heap()->illegal_argument_string());
13597 } 13598 }
13598 13599
13599 v8::String::Utf8Value utf8_locale_id( 13600 v8::String::Utf8Value utf8_locale_id(
13600 v8::Utils::ToLocal(Handle<String>(String::cast(locale_id)))); 13601 v8::Utils::ToLocal(Handle<String>(String::cast(locale_id))));
13601 13602
13602 UErrorCode error = U_ZERO_ERROR; 13603 UErrorCode error = U_ZERO_ERROR;
13603 13604
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after
14723 // Handle last resort GC and make sure to allow future allocations 14724 // Handle last resort GC and make sure to allow future allocations
14724 // to grow the heap without causing GCs (if possible). 14725 // to grow the heap without causing GCs (if possible).
14725 isolate->counters()->gc_last_resort_from_js()->Increment(); 14726 isolate->counters()->gc_last_resort_from_js()->Increment();
14726 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14727 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14727 "Runtime::PerformGC"); 14728 "Runtime::PerformGC");
14728 } 14729 }
14729 } 14730 }
14730 14731
14731 14732
14732 } } // namespace v8::internal 14733 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698