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

Side by Side Diff: src/runtime.cc

Issue 240253003: Remove uses of MaybeObject in runtime.cc. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: changed as suggested Created 6 years, 8 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/compiler.cc ('k') | no next file » | 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 7027 matching lines...) Expand 10 before | Expand all | Expand 10 after
7038 isolate, result, isolate->factory()->NewConsString(str1, str2)); 7038 isolate, result, isolate->factory()->NewConsString(str1, str2));
7039 return *result; 7039 return *result;
7040 } 7040 }
7041 7041
7042 7042
7043 template <typename sinkchar> 7043 template <typename sinkchar>
7044 static inline void StringBuilderConcatHelper(String* special, 7044 static inline void StringBuilderConcatHelper(String* special,
7045 sinkchar* sink, 7045 sinkchar* sink,
7046 FixedArray* fixed_array, 7046 FixedArray* fixed_array,
7047 int array_length) { 7047 int array_length) {
7048 DisallowHeapAllocation no_gc;
7048 int position = 0; 7049 int position = 0;
7049 for (int i = 0; i < array_length; i++) { 7050 for (int i = 0; i < array_length; i++) {
7050 Object* element = fixed_array->get(i); 7051 Object* element = fixed_array->get(i);
7051 if (element->IsSmi()) { 7052 if (element->IsSmi()) {
7052 // Smi encoding of position and length. 7053 // Smi encoding of position and length.
7053 int encoded_slice = Smi::cast(element)->value(); 7054 int encoded_slice = Smi::cast(element)->value();
7054 int pos; 7055 int pos;
7055 int len; 7056 int len;
7056 if (encoded_slice > 0) { 7057 if (encoded_slice > 0) {
7057 // Position and length encoded in one smi. 7058 // Position and length encoded in one smi.
(...skipping 14 matching lines...) Expand all
7072 } else { 7073 } else {
7073 String* string = String::cast(element); 7074 String* string = String::cast(element);
7074 int element_length = string->length(); 7075 int element_length = string->length();
7075 String::WriteToFlat(string, sink + position, 0, element_length); 7076 String::WriteToFlat(string, sink + position, 0, element_length);
7076 position += element_length; 7077 position += element_length;
7077 } 7078 }
7078 } 7079 }
7079 } 7080 }
7080 7081
7081 7082
7082 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) { 7083 // Returns the result length of the concatenation.
7083 HandleScope scope(isolate); 7084 // On illegal argument, -1 is returned.
7084 ASSERT(args.length() == 3); 7085 static inline int StringBuilderConcatLength(int special_length,
7085 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); 7086 FixedArray* fixed_array,
7086 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength(); 7087 int array_length,
7087 int array_length = args.smi_at(1); 7088 bool* one_byte) {
7088 CONVERT_ARG_HANDLE_CHECKED(String, special, 2); 7089 DisallowHeapAllocation no_gc;
7089
7090 // This assumption is used by the slice encoding in one or two smis.
7091 ASSERT(Smi::kMaxValue >= String::kMaxLength);
7092
7093 JSObject::EnsureCanContainHeapObjectElements(array);
7094
7095 int special_length = special->length();
7096 if (!array->HasFastObjectElements()) {
7097 return isolate->Throw(isolate->heap()->illegal_argument_string());
7098 }
7099 FixedArray* fixed_array = FixedArray::cast(array->elements());
7100 if (fixed_array->length() < array_length) {
7101 array_length = fixed_array->length();
7102 }
7103
7104 if (array_length == 0) {
7105 return isolate->heap()->empty_string();
7106 } else if (array_length == 1) {
7107 Object* first = fixed_array->get(0);
7108 if (first->IsString()) return first;
7109 }
7110
7111 bool one_byte = special->HasOnlyOneByteChars();
7112 int position = 0; 7090 int position = 0;
7113 for (int i = 0; i < array_length; i++) { 7091 for (int i = 0; i < array_length; i++) {
7114 int increment = 0; 7092 int increment = 0;
7115 Object* elt = fixed_array->get(i); 7093 Object* elt = fixed_array->get(i);
7116 if (elt->IsSmi()) { 7094 if (elt->IsSmi()) {
7117 // Smi encoding of position and length. 7095 // Smi encoding of position and length.
7118 int smi_value = Smi::cast(elt)->value(); 7096 int smi_value = Smi::cast(elt)->value();
7119 int pos; 7097 int pos;
7120 int len; 7098 int len;
7121 if (smi_value > 0) { 7099 if (smi_value > 0) {
7122 // Position and length encoded in one smi. 7100 // Position and length encoded in one smi.
7123 pos = StringBuilderSubstringPosition::decode(smi_value); 7101 pos = StringBuilderSubstringPosition::decode(smi_value);
7124 len = StringBuilderSubstringLength::decode(smi_value); 7102 len = StringBuilderSubstringLength::decode(smi_value);
7125 } else { 7103 } else {
7126 // Position and length encoded in two smis. 7104 // Position and length encoded in two smis.
7127 len = -smi_value; 7105 len = -smi_value;
7128 // Get the position and check that it is a positive smi. 7106 // Get the position and check that it is a positive smi.
7129 i++; 7107 i++;
7130 if (i >= array_length) { 7108 if (i >= array_length) return -1;
7131 return isolate->Throw(isolate->heap()->illegal_argument_string());
7132 }
7133 Object* next_smi = fixed_array->get(i); 7109 Object* next_smi = fixed_array->get(i);
7134 if (!next_smi->IsSmi()) { 7110 if (!next_smi->IsSmi()) return -1;
7135 return isolate->Throw(isolate->heap()->illegal_argument_string());
7136 }
7137 pos = Smi::cast(next_smi)->value(); 7111 pos = Smi::cast(next_smi)->value();
7138 if (pos < 0) { 7112 if (pos < 0) return -1;
7139 return isolate->Throw(isolate->heap()->illegal_argument_string());
7140 }
7141 } 7113 }
7142 ASSERT(pos >= 0); 7114 ASSERT(pos >= 0);
7143 ASSERT(len >= 0); 7115 ASSERT(len >= 0);
7144 if (pos > special_length || len > special_length - pos) { 7116 if (pos > special_length || len > special_length - pos) return -1;
7145 return isolate->Throw(isolate->heap()->illegal_argument_string());
7146 }
7147 increment = len; 7117 increment = len;
7148 } else if (elt->IsString()) { 7118 } else if (elt->IsString()) {
7149 String* element = String::cast(elt); 7119 String* element = String::cast(elt);
7150 int element_length = element->length(); 7120 int element_length = element->length();
7151 increment = element_length; 7121 increment = element_length;
7152 if (one_byte && !element->HasOnlyOneByteChars()) { 7122 if (*one_byte && !element->HasOnlyOneByteChars()) {
7153 one_byte = false; 7123 *one_byte = false;
7154 } 7124 }
7155 } else { 7125 } else {
7156 ASSERT(!elt->IsTheHole()); 7126 ASSERT(!elt->IsTheHole());
7157 return isolate->Throw(isolate->heap()->illegal_argument_string()); 7127 return -1;
7158 } 7128 }
7159 if (increment > String::kMaxLength - position) { 7129 if (increment > String::kMaxLength - position) {
7160 return isolate->ThrowInvalidStringLength(); 7130 return kMaxInt; // Provoke throw on allocation.
7161 } 7131 }
7162 position += increment; 7132 position += increment;
7163 } 7133 }
7134 return position;
7135 }
7164 7136
7165 int length = position; 7137
7166 Object* object; 7138 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) {
7139 HandleScope scope(isolate);
7140 ASSERT(args.length() == 3);
7141 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0);
7142 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength();
7143 int array_length = args.smi_at(1);
7144 CONVERT_ARG_HANDLE_CHECKED(String, special, 2);
7145
7146 // This assumption is used by the slice encoding in one or two smis.
7147 ASSERT(Smi::kMaxValue >= String::kMaxLength);
7148
7149 JSObject::EnsureCanContainHeapObjectElements(array);
7150
7151 int special_length = special->length();
7152 if (!array->HasFastObjectElements()) {
7153 return isolate->Throw(isolate->heap()->illegal_argument_string());
7154 }
7155
7156 int length;
7157 bool one_byte = special->HasOnlyOneByteChars();
7158
7159 { DisallowHeapAllocation no_gc;
7160 FixedArray* fixed_array = FixedArray::cast(array->elements());
7161 if (fixed_array->length() < array_length) {
7162 array_length = fixed_array->length();
7163 }
7164
7165 if (array_length == 0) {
7166 return isolate->heap()->empty_string();
7167 } else if (array_length == 1) {
7168 Object* first = fixed_array->get(0);
7169 if (first->IsString()) return first;
7170 }
7171 length = StringBuilderConcatLength(
7172 special_length, fixed_array, array_length, &one_byte);
7173 }
7174
7175 if (length == -1) {
7176 return isolate->Throw(isolate->heap()->illegal_argument_string());
7177 }
7167 7178
7168 if (one_byte) { 7179 if (one_byte) {
7169 { MaybeObject* maybe_object = 7180 Handle<SeqOneByteString> answer;
7170 isolate->heap()->AllocateRawOneByteString(length); 7181 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
7171 if (!maybe_object->ToObject(&object)) return maybe_object; 7182 isolate, answer,
7172 } 7183 isolate->factory()->NewRawOneByteString(length));
7173 SeqOneByteString* answer = SeqOneByteString::cast(object);
7174 StringBuilderConcatHelper(*special, 7184 StringBuilderConcatHelper(*special,
7175 answer->GetChars(), 7185 answer->GetChars(),
7176 fixed_array, 7186 FixedArray::cast(array->elements()),
7177 array_length); 7187 array_length);
7178 return answer; 7188 return *answer;
7179 } else { 7189 } else {
7180 { MaybeObject* maybe_object = 7190 Handle<SeqTwoByteString> answer;
7181 isolate->heap()->AllocateRawTwoByteString(length); 7191 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
7182 if (!maybe_object->ToObject(&object)) return maybe_object; 7192 isolate, answer,
7183 } 7193 isolate->factory()->NewRawTwoByteString(length));
7184 SeqTwoByteString* answer = SeqTwoByteString::cast(object);
7185 StringBuilderConcatHelper(*special, 7194 StringBuilderConcatHelper(*special,
7186 answer->GetChars(), 7195 answer->GetChars(),
7187 fixed_array, 7196 FixedArray::cast(array->elements()),
7188 array_length); 7197 array_length);
7189 return answer; 7198 return *answer;
7190 } 7199 }
7191 } 7200 }
7192 7201
7193 7202
7194 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderJoin) { 7203 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderJoin) {
7195 HandleScope scope(isolate); 7204 HandleScope scope(isolate);
7196 ASSERT(args.length() == 3); 7205 ASSERT(args.length() == 3);
7197 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); 7206 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0);
7198 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength(); 7207 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength();
7199 int array_length = args.smi_at(1); 7208 int array_length = args.smi_at(1);
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after
8807 Handle<Object> argv_small_buffer[argv_small_size]; 8816 Handle<Object> argv_small_buffer[argv_small_size];
8808 SmartArrayPointer<Handle<Object> > argv_large_buffer; 8817 SmartArrayPointer<Handle<Object> > argv_large_buffer;
8809 Handle<Object>* argv = argv_small_buffer; 8818 Handle<Object>* argv = argv_small_buffer;
8810 if (argc > argv_small_size) { 8819 if (argc > argv_small_size) {
8811 argv = new Handle<Object>[argc]; 8820 argv = new Handle<Object>[argc];
8812 if (argv == NULL) return isolate->StackOverflow(); 8821 if (argv == NULL) return isolate->StackOverflow();
8813 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv); 8822 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv);
8814 } 8823 }
8815 8824
8816 for (int i = 0; i < argc; ++i) { 8825 for (int i = 0; i < argc; ++i) {
8817 MaybeObject* maybe = args[1 + i]; 8826 argv[i] = Handle<Object>(args[1 + i], isolate);
8818 Object* object;
8819 if (!maybe->To<Object>(&object)) return maybe;
8820 argv[i] = Handle<Object>(object, isolate);
8821 } 8827 }
8822 8828
8823 Handle<JSReceiver> hfun(fun); 8829 Handle<JSReceiver> hfun(fun);
8824 Handle<Object> hreceiver(receiver, isolate); 8830 Handle<Object> hreceiver(receiver, isolate);
8825 Handle<Object> result; 8831 Handle<Object> result;
8826 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 8832 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
8827 isolate, result, 8833 isolate, result,
8828 Execution::Call(isolate, hfun, hreceiver, argc, argv, true)); 8834 Execution::Call(isolate, hfun, hreceiver, argc, argv, true));
8829 return *result; 8835 return *result;
8830 } 8836 }
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
9709 !CodeGenerationFromStringsAllowed(isolate, context)) { 9715 !CodeGenerationFromStringsAllowed(isolate, context)) {
9710 Handle<Object> error_message = 9716 Handle<Object> error_message =
9711 context->ErrorMessageForCodeGenerationFromStrings(); 9717 context->ErrorMessageForCodeGenerationFromStrings();
9712 return isolate->Throw(*isolate->factory()->NewEvalError( 9718 return isolate->Throw(*isolate->factory()->NewEvalError(
9713 "code_gen_from_strings", HandleVector<Object>(&error_message, 1))); 9719 "code_gen_from_strings", HandleVector<Object>(&error_message, 1)));
9714 } 9720 }
9715 9721
9716 // Compile source string in the native context. 9722 // Compile source string in the native context.
9717 ParseRestriction restriction = function_literal_only 9723 ParseRestriction restriction = function_literal_only
9718 ? ONLY_SINGLE_FUNCTION_LITERAL : NO_PARSE_RESTRICTION; 9724 ? ONLY_SINGLE_FUNCTION_LITERAL : NO_PARSE_RESTRICTION;
9719 Handle<JSFunction> fun = Compiler::GetFunctionFromEval( 9725 Handle<JSFunction> fun;
9720 source, context, SLOPPY, restriction, RelocInfo::kNoPosition); 9726 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
9721 RETURN_IF_EMPTY_HANDLE(isolate, fun); 9727 isolate, fun,
9728 Compiler::GetFunctionFromEval(
9729 source, context, SLOPPY, restriction, RelocInfo::kNoPosition));
9722 return *fun; 9730 return *fun;
9723 } 9731 }
9724 9732
9725 9733
9726 static ObjectPair CompileGlobalEval(Isolate* isolate, 9734 static ObjectPair CompileGlobalEval(Isolate* isolate,
9727 Handle<String> source, 9735 Handle<String> source,
9728 Handle<Object> receiver, 9736 Handle<Object> receiver,
9729 StrictMode strict_mode, 9737 StrictMode strict_mode,
9730 int scope_position) { 9738 int scope_position) {
9731 Handle<Context> context = Handle<Context>(isolate->context()); 9739 Handle<Context> context = Handle<Context>(isolate->context());
9732 Handle<Context> native_context = Handle<Context>(context->native_context()); 9740 Handle<Context> native_context = Handle<Context>(context->native_context());
9733 9741
9734 // Check if native context allows code generation from 9742 // Check if native context allows code generation from
9735 // strings. Throw an exception if it doesn't. 9743 // strings. Throw an exception if it doesn't.
9736 if (native_context->allow_code_gen_from_strings()->IsFalse() && 9744 if (native_context->allow_code_gen_from_strings()->IsFalse() &&
9737 !CodeGenerationFromStringsAllowed(isolate, native_context)) { 9745 !CodeGenerationFromStringsAllowed(isolate, native_context)) {
9738 Handle<Object> error_message = 9746 Handle<Object> error_message =
9739 native_context->ErrorMessageForCodeGenerationFromStrings(); 9747 native_context->ErrorMessageForCodeGenerationFromStrings();
9740 isolate->Throw(*isolate->factory()->NewEvalError( 9748 isolate->Throw(*isolate->factory()->NewEvalError(
9741 "code_gen_from_strings", HandleVector<Object>(&error_message, 1))); 9749 "code_gen_from_strings", HandleVector<Object>(&error_message, 1)));
9742 return MakePair(Failure::Exception(), NULL); 9750 return MakePair(Failure::Exception(), NULL);
9743 } 9751 }
9744 9752
9745 // Deal with a normal eval call with a string argument. Compile it 9753 // Deal with a normal eval call with a string argument. Compile it
9746 // and return the compiled function bound in the local context. 9754 // and return the compiled function bound in the local context.
9747 static const ParseRestriction restriction = NO_PARSE_RESTRICTION; 9755 static const ParseRestriction restriction = NO_PARSE_RESTRICTION;
9748 Handle<JSFunction> compiled = Compiler::GetFunctionFromEval( 9756 Handle<JSFunction> compiled;
9749 source, context, strict_mode, restriction, scope_position); 9757 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
9750 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, compiled, 9758 isolate, compiled,
9751 MakePair(Failure::Exception(), NULL)); 9759 Compiler::GetFunctionFromEval(
9760 source, context, strict_mode, restriction, scope_position),
9761 MakePair(Failure::Exception(), NULL));
9752 return MakePair(*compiled, *receiver); 9762 return MakePair(*compiled, *receiver);
9753 } 9763 }
9754 9764
9755 9765
9756 RUNTIME_FUNCTION(ObjectPair, RuntimeHidden_ResolvePossiblyDirectEval) { 9766 RUNTIME_FUNCTION(ObjectPair, RuntimeHidden_ResolvePossiblyDirectEval) {
9757 HandleScope scope(isolate); 9767 HandleScope scope(isolate);
9758 ASSERT(args.length() == 5); 9768 ASSERT(args.length() == 5);
9759 9769
9760 Handle<Object> callee = args.at<Object>(0); 9770 Handle<Object> callee = args.at<Object>(0);
9761 9771
(...skipping 3002 matching lines...) Expand 10 before | Expand all | Expand 10 after
12764 RETURN_ON_EXCEPTION( 12774 RETURN_ON_EXCEPTION(
12765 isolate, 12775 isolate,
12766 Runtime::SetObjectProperty( 12776 Runtime::SetObjectProperty(
12767 isolate, target, arguments_str, arguments, ::NONE, SLOPPY), 12777 isolate, target, arguments_str, arguments, ::NONE, SLOPPY),
12768 JSObject); 12778 JSObject);
12769 return target; 12779 return target;
12770 } 12780 }
12771 12781
12772 12782
12773 // Compile and evaluate source for the given context. 12783 // Compile and evaluate source for the given context.
12774 static MaybeObject* DebugEvaluate(Isolate* isolate, 12784 static MaybeHandle<Object> DebugEvaluate(Isolate* isolate,
12775 Handle<Context> context, 12785 Handle<Context> context,
12776 Handle<Object> context_extension, 12786 Handle<Object> context_extension,
12777 Handle<Object> receiver, 12787 Handle<Object> receiver,
12778 Handle<String> source) { 12788 Handle<String> source) {
12779 if (context_extension->IsJSObject()) { 12789 if (context_extension->IsJSObject()) {
12780 Handle<JSObject> extension = Handle<JSObject>::cast(context_extension); 12790 Handle<JSObject> extension = Handle<JSObject>::cast(context_extension);
12781 Handle<JSFunction> closure(context->closure(), isolate); 12791 Handle<JSFunction> closure(context->closure(), isolate);
12782 context = isolate->factory()->NewWithContext(closure, context, extension); 12792 context = isolate->factory()->NewWithContext(closure, context, extension);
12783 } 12793 }
12784 12794
12785 Handle<JSFunction> eval_fun = 12795 Handle<JSFunction> eval_fun;
12796 ASSIGN_RETURN_ON_EXCEPTION(
12797 isolate, eval_fun,
12786 Compiler::GetFunctionFromEval(source, 12798 Compiler::GetFunctionFromEval(source,
12787 context, 12799 context,
12788 SLOPPY, 12800 SLOPPY,
12789 NO_PARSE_RESTRICTION, 12801 NO_PARSE_RESTRICTION,
12790 RelocInfo::kNoPosition); 12802 RelocInfo::kNoPosition),
12791 RETURN_IF_EMPTY_HANDLE(isolate, eval_fun); 12803 Object);
12792 12804
12793 Handle<Object> result; 12805 Handle<Object> result;
12794 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 12806 ASSIGN_RETURN_ON_EXCEPTION(
12795 isolate, result, 12807 isolate, result,
12796 Execution::Call(isolate, eval_fun, receiver, 0, NULL)); 12808 Execution::Call(isolate, eval_fun, receiver, 0, NULL),
12809 Object);
12797 12810
12798 // Skip the global proxy as it has no properties and always delegates to the 12811 // Skip the global proxy as it has no properties and always delegates to the
12799 // real global object. 12812 // real global object.
12800 if (result->IsJSGlobalProxy()) { 12813 if (result->IsJSGlobalProxy()) {
12801 result = Handle<JSObject>(JSObject::cast(result->GetPrototype(isolate))); 12814 result = Handle<JSObject>(JSObject::cast(result->GetPrototype(isolate)));
12802 } 12815 }
12803 12816
12804 // Clear the oneshot breakpoints so that the debugger does not step further. 12817 // Clear the oneshot breakpoints so that the debugger does not step further.
12805 isolate->debug()->ClearStepping(); 12818 isolate->debug()->ClearStepping();
12806 return *result; 12819 return result;
12807 } 12820 }
12808 12821
12809 12822
12810 // Evaluate a piece of JavaScript in the context of a stack frame for 12823 // Evaluate a piece of JavaScript in the context of a stack frame for
12811 // debugging. Things that need special attention are: 12824 // debugging. Things that need special attention are:
12812 // - Parameters and stack-allocated locals need to be materialized. Altered 12825 // - Parameters and stack-allocated locals need to be materialized. Altered
12813 // values need to be written back to the stack afterwards. 12826 // values need to be written back to the stack afterwards.
12814 // - The arguments object needs to materialized. 12827 // - The arguments object needs to materialized.
12815 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluate) { 12828 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluate) {
12816 HandleScope scope(isolate); 12829 HandleScope scope(isolate);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
12860 isolate, materialized, function, &frame_inspector)); 12873 isolate, materialized, function, &frame_inspector));
12861 12874
12862 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 12875 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
12863 isolate, materialized, 12876 isolate, materialized,
12864 MaterializeArgumentsObject(isolate, materialized, function)); 12877 MaterializeArgumentsObject(isolate, materialized, function));
12865 12878
12866 // Add the materialized object in a with-scope to shadow the stack locals. 12879 // Add the materialized object in a with-scope to shadow the stack locals.
12867 context = isolate->factory()->NewWithContext(function, context, materialized); 12880 context = isolate->factory()->NewWithContext(function, context, materialized);
12868 12881
12869 Handle<Object> receiver(frame->receiver(), isolate); 12882 Handle<Object> receiver(frame->receiver(), isolate);
12870 Object* evaluate_result_object; 12883 Handle<Object> result;
12871 { MaybeObject* maybe_result = 12884 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
12872 DebugEvaluate(isolate, context, context_extension, receiver, source); 12885 isolate, result,
12873 if (!maybe_result->ToObject(&evaluate_result_object)) return maybe_result; 12886 DebugEvaluate(isolate, context, context_extension, receiver, source));
12874 }
12875
12876 Handle<Object> result(evaluate_result_object, isolate);
12877 12887
12878 // Write back potential changes to materialized stack locals to the stack. 12888 // Write back potential changes to materialized stack locals to the stack.
12879 UpdateStackLocalsFromMaterializedObject( 12889 UpdateStackLocalsFromMaterializedObject(
12880 isolate, materialized, function, frame, inlined_jsframe_index); 12890 isolate, materialized, function, frame, inlined_jsframe_index);
12881 12891
12882 return *result; 12892 return *result;
12883 } 12893 }
12884 12894
12885 12895
12886 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluateGlobal) { 12896 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluateGlobal) {
(...skipping 21 matching lines...) Expand all
12908 top = top->prev(); 12918 top = top->prev();
12909 } 12919 }
12910 if (top != NULL) { 12920 if (top != NULL) {
12911 isolate->set_context(*top->context()); 12921 isolate->set_context(*top->context());
12912 } 12922 }
12913 12923
12914 // Get the native context now set to the top context from before the 12924 // Get the native context now set to the top context from before the
12915 // debugger was invoked. 12925 // debugger was invoked.
12916 Handle<Context> context = isolate->native_context(); 12926 Handle<Context> context = isolate->native_context();
12917 Handle<Object> receiver = isolate->global_object(); 12927 Handle<Object> receiver = isolate->global_object();
12918 return DebugEvaluate(isolate, context, context_extension, receiver, source); 12928 Handle<Object> result;
12929 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
12930 isolate, result,
12931 DebugEvaluate(isolate, context, context_extension, receiver, source));
12932 return *result;
12919 } 12933 }
12920 12934
12921 12935
12922 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetLoadedScripts) { 12936 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetLoadedScripts) {
12923 HandleScope scope(isolate); 12937 HandleScope scope(isolate);
12924 ASSERT(args.length() == 0); 12938 ASSERT(args.length() == 0);
12925 12939
12926 // Fill the script objects. 12940 // Fill the script objects.
12927 Handle<FixedArray> instances = isolate->debug()->GetLoadedScripts(); 12941 Handle<FixedArray> instances = isolate->debug()->GetLoadedScripts();
12928 12942
(...skipping 2152 matching lines...) Expand 10 before | Expand all | Expand 10 after
15081 } 15095 }
15082 } 15096 }
15083 15097
15084 15098
15085 void Runtime::OutOfMemory() { 15099 void Runtime::OutOfMemory() {
15086 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); 15100 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true);
15087 UNREACHABLE(); 15101 UNREACHABLE();
15088 } 15102 }
15089 15103
15090 } } // namespace v8::internal 15104 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698