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

Side by Side Diff: src/factory.cc

Issue 235083002: Reland "Handlify GetProperty." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix 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/execution.cc ('k') | src/handles.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 "factory.h" 5 #include "factory.h"
6 6
7 #include "isolate-inl.h" 7 #include "isolate-inl.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 OS::StrNCpy(v, message, space); 1115 OS::StrNCpy(v, message, space);
1116 space -= Min(space, strlen(message)); 1116 space -= Min(space, strlen(message));
1117 p = &buffer[kBufferSize] - space; 1117 p = &buffer[kBufferSize] - space;
1118 1118
1119 for (unsigned i = 0; i < ARRAY_SIZE(args); i++) { 1119 for (unsigned i = 0; i < ARRAY_SIZE(args); i++) {
1120 if (space > 0) { 1120 if (space > 0) {
1121 *p++ = ' '; 1121 *p++ = ' ';
1122 space--; 1122 space--;
1123 if (space > 0) { 1123 if (space > 0) {
1124 Handle<String> arg_str = Handle<String>::cast( 1124 Handle<String> arg_str = Handle<String>::cast(
1125 Object::GetElementNoExceptionThrown(isolate(), args, i)); 1125 Object::GetElement(isolate(), args, i).ToHandleChecked());
1126 SmartArrayPointer<char> arg = arg_str->ToCString(); 1126 SmartArrayPointer<char> arg = arg_str->ToCString();
1127 Vector<char> v2(p, static_cast<int>(space)); 1127 Vector<char> v2(p, static_cast<int>(space));
1128 OS::StrNCpy(v2, arg.get(), space); 1128 OS::StrNCpy(v2, arg.get(), space);
1129 space -= Min(space, strlen(arg.get())); 1129 space -= Min(space, strlen(arg.get()));
1130 p = &buffer[kBufferSize] - space; 1130 p = &buffer[kBufferSize] - space;
1131 } 1131 }
1132 } 1132 }
1133 } 1133 }
1134 if (space > 0) { 1134 if (space > 0) {
1135 *p = '\0'; 1135 *p = '\0';
1136 } else { 1136 } else {
1137 buffer[kBufferSize - 1] = '\0'; 1137 buffer[kBufferSize - 1] = '\0';
1138 } 1138 }
1139 Handle<String> error_string = NewStringFromUtf8(CStrVector(buffer), TENURED); 1139 Handle<String> error_string = NewStringFromUtf8(CStrVector(buffer), TENURED);
1140 return error_string; 1140 return error_string;
1141 } 1141 }
1142 1142
1143 1143
1144 Handle<Object> Factory::NewError(const char* maker, 1144 Handle<Object> Factory::NewError(const char* maker,
1145 const char* message, 1145 const char* message,
1146 Handle<JSArray> args) { 1146 Handle<JSArray> args) {
1147 Handle<String> make_str = InternalizeUtf8String(maker); 1147 Handle<String> make_str = InternalizeUtf8String(maker);
1148 Handle<Object> fun_obj = GlobalObject::GetPropertyNoExceptionThrown( 1148 Handle<Object> fun_obj = Object::GetProperty(
1149 isolate()->js_builtins_object(), make_str); 1149 isolate()->js_builtins_object(), make_str).ToHandleChecked();
1150 // If the builtins haven't been properly configured yet this error 1150 // If the builtins haven't been properly configured yet this error
1151 // constructor may not have been defined. Bail out. 1151 // constructor may not have been defined. Bail out.
1152 if (!fun_obj->IsJSFunction()) { 1152 if (!fun_obj->IsJSFunction()) {
1153 return EmergencyNewError(message, args); 1153 return EmergencyNewError(message, args);
1154 } 1154 }
1155 Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj); 1155 Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj);
1156 Handle<Object> message_obj = InternalizeUtf8String(message); 1156 Handle<Object> message_obj = InternalizeUtf8String(message);
1157 Handle<Object> argv[] = { message_obj, args }; 1157 Handle<Object> argv[] = { message_obj, args };
1158 1158
1159 // Invoke the JavaScript factory method. If an exception is thrown while 1159 // Invoke the JavaScript factory method. If an exception is thrown while
(...skipping 12 matching lines...) Expand all
1172 1172
1173 1173
1174 Handle<Object> Factory::NewError(Handle<String> message) { 1174 Handle<Object> Factory::NewError(Handle<String> message) {
1175 return NewError("$Error", message); 1175 return NewError("$Error", message);
1176 } 1176 }
1177 1177
1178 1178
1179 Handle<Object> Factory::NewError(const char* constructor, 1179 Handle<Object> Factory::NewError(const char* constructor,
1180 Handle<String> message) { 1180 Handle<String> message) {
1181 Handle<String> constr = InternalizeUtf8String(constructor); 1181 Handle<String> constr = InternalizeUtf8String(constructor);
1182 Handle<JSFunction> fun = Handle<JSFunction>::cast( 1182 Handle<JSFunction> fun = Handle<JSFunction>::cast(Object::GetProperty(
1183 GlobalObject::GetPropertyNoExceptionThrown( 1183 isolate()->js_builtins_object(), constr).ToHandleChecked());
1184 isolate()->js_builtins_object(), constr));
1185 Handle<Object> argv[] = { message }; 1184 Handle<Object> argv[] = { message };
1186 1185
1187 // Invoke the JavaScript factory method. If an exception is thrown while 1186 // Invoke the JavaScript factory method. If an exception is thrown while
1188 // running the factory method, use the exception as the result. 1187 // running the factory method, use the exception as the result.
1189 Handle<Object> result; 1188 Handle<Object> result;
1190 Handle<Object> exception; 1189 Handle<Object> exception;
1191 if (!Execution::TryCall(fun, 1190 if (!Execution::TryCall(fun,
1192 isolate()->js_builtins_object(), 1191 isolate()->js_builtins_object(),
1193 ARRAY_SIZE(argv), 1192 ARRAY_SIZE(argv),
1194 argv, 1193 argv,
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
2018 if (String::Equals(name, infinity_string())) return infinity_value(); 2017 if (String::Equals(name, infinity_string())) return infinity_value();
2019 return Handle<Object>::null(); 2018 return Handle<Object>::null();
2020 } 2019 }
2021 2020
2022 2021
2023 Handle<Object> Factory::ToBoolean(bool value) { 2022 Handle<Object> Factory::ToBoolean(bool value) {
2024 return value ? true_value() : false_value(); 2023 return value ? true_value() : false_value();
2025 } 2024 }
2026 2025
2027 } } // namespace v8::internal 2026 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/execution.cc ('k') | src/handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698