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

Side by Side Diff: src/factory.cc

Issue 1423723002: Map v8::Function to JSReceiver + IsCallable (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 1 month 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
« no previous file with comments | « src/execution.cc ('k') | src/full-codegen/full-codegen.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/factory.h" 5 #include "src/factory.h"
6 6
7 #include "src/allocation-site-scopes.h" 7 #include "src/allocation-site-scopes.h"
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 Handle<Object> message_type(Smi::FromInt(template_index), isolate()); 1115 Handle<Object> message_type(Smi::FromInt(template_index), isolate());
1116 if (arg0.is_null()) arg0 = undefined_value(); 1116 if (arg0.is_null()) arg0 = undefined_value();
1117 if (arg1.is_null()) arg1 = undefined_value(); 1117 if (arg1.is_null()) arg1 = undefined_value();
1118 if (arg2.is_null()) arg2 = undefined_value(); 1118 if (arg2.is_null()) arg2 = undefined_value();
1119 Handle<Object> argv[] = {constructor, message_type, arg0, arg1, arg2}; 1119 Handle<Object> argv[] = {constructor, message_type, arg0, arg1, arg2};
1120 1120
1121 // Invoke the JavaScript factory method. If an exception is thrown while 1121 // Invoke the JavaScript factory method. If an exception is thrown while
1122 // running the factory method, use the exception as the result. 1122 // running the factory method, use the exception as the result.
1123 Handle<Object> result; 1123 Handle<Object> result;
1124 MaybeHandle<Object> exception; 1124 MaybeHandle<Object> exception;
1125 if (!Execution::TryCall(fun, undefined_value(), arraysize(argv), argv, 1125 if (!Execution::TryCall(isolate(), fun, undefined_value(), arraysize(argv),
1126 &exception) 1126 argv, &exception)
1127 .ToHandle(&result)) { 1127 .ToHandle(&result)) {
1128 Handle<Object> exception_obj; 1128 Handle<Object> exception_obj;
1129 if (exception.ToHandle(&exception_obj)) { 1129 if (exception.ToHandle(&exception_obj)) {
1130 result = exception_obj; 1130 result = exception_obj;
1131 } else { 1131 } else {
1132 result = undefined_value(); 1132 result = undefined_value();
1133 } 1133 }
1134 } 1134 }
1135 return scope.CloseAndEscape(result); 1135 return scope.CloseAndEscape(result);
1136 } 1136 }
1137 1137
1138 1138
1139 Handle<Object> Factory::NewError(Handle<JSFunction> constructor, 1139 Handle<Object> Factory::NewError(Handle<JSFunction> constructor,
1140 Handle<String> message) { 1140 Handle<String> message) {
1141 Handle<Object> argv[] = { message }; 1141 Handle<Object> argv[] = { message };
1142 1142
1143 // Invoke the JavaScript factory method. If an exception is thrown while 1143 // Invoke the JavaScript factory method. If an exception is thrown while
1144 // running the factory method, use the exception as the result. 1144 // running the factory method, use the exception as the result.
1145 Handle<Object> result; 1145 Handle<Object> result;
1146 MaybeHandle<Object> exception; 1146 MaybeHandle<Object> exception;
1147 if (!Execution::TryCall(constructor, undefined_value(), arraysize(argv), argv, 1147 if (!Execution::TryCall(isolate(), constructor, undefined_value(),
1148 &exception) 1148 arraysize(argv), argv, &exception)
1149 .ToHandle(&result)) { 1149 .ToHandle(&result)) {
1150 Handle<Object> exception_obj; 1150 Handle<Object> exception_obj;
1151 if (exception.ToHandle(&exception_obj)) return exception_obj; 1151 if (exception.ToHandle(&exception_obj)) return exception_obj;
1152 return undefined_value(); 1152 return undefined_value();
1153 } 1153 }
1154 return result; 1154 return result;
1155 } 1155 }
1156 1156
1157 1157
1158 #define DEFINE_ERROR(NAME, name) \ 1158 #define DEFINE_ERROR(NAME, name) \
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2384 } 2384 }
2385 2385
2386 2386
2387 Handle<Object> Factory::ToBoolean(bool value) { 2387 Handle<Object> Factory::ToBoolean(bool value) {
2388 return value ? true_value() : false_value(); 2388 return value ? true_value() : false_value();
2389 } 2389 }
2390 2390
2391 2391
2392 } // namespace internal 2392 } // namespace internal
2393 } // namespace v8 2393 } // namespace v8
OLDNEW
« no previous file with comments | « src/execution.cc ('k') | src/full-codegen/full-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698