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

Side by Side Diff: src/runtime/runtime-array.cc

Issue 976693002: Revert of Implement subclassing Arrays. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « src/runtime/runtime.h ('k') | src/x64/code-stubs-x64.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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/runtime/runtime-utils.h" 8 #include "src/runtime/runtime-utils.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements() || 1031 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements() ||
1032 array->HasFastDoubleElements()); 1032 array->HasFastDoubleElements());
1033 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); 1033 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length());
1034 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length)); 1034 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length));
1035 } 1035 }
1036 } 1036 }
1037 1037
1038 1038
1039 static Object* ArrayConstructorCommon(Isolate* isolate, 1039 static Object* ArrayConstructorCommon(Isolate* isolate,
1040 Handle<JSFunction> constructor, 1040 Handle<JSFunction> constructor,
1041 Handle<JSFunction> original_constructor,
1042 Handle<AllocationSite> site, 1041 Handle<AllocationSite> site,
1043 Arguments* caller_args) { 1042 Arguments* caller_args) {
1044 Factory* factory = isolate->factory(); 1043 Factory* factory = isolate->factory();
1045 1044
1046 bool holey = false; 1045 bool holey = false;
1047 bool can_use_type_feedback = true; 1046 bool can_use_type_feedback = true;
1048 if (caller_args->length() == 1) { 1047 if (caller_args->length() == 1) {
1049 Handle<Object> argument_one = caller_args->at<Object>(0); 1048 Handle<Object> argument_one = caller_args->at<Object>(0);
1050 if (argument_one->IsSmi()) { 1049 if (argument_one->IsSmi()) {
1051 int value = Handle<Smi>::cast(argument_one)->value(); 1050 int value = Handle<Smi>::cast(argument_one)->value();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 ElementsKind old_kind = array->GetElementsKind(); 1102 ElementsKind old_kind = array->GetElementsKind();
1104 RETURN_FAILURE_ON_EXCEPTION( 1103 RETURN_FAILURE_ON_EXCEPTION(
1105 isolate, ArrayConstructInitializeElements(array, caller_args)); 1104 isolate, ArrayConstructInitializeElements(array, caller_args));
1106 if (!site.is_null() && 1105 if (!site.is_null() &&
1107 (old_kind != array->GetElementsKind() || !can_use_type_feedback)) { 1106 (old_kind != array->GetElementsKind() || !can_use_type_feedback)) {
1108 // The arguments passed in caused a transition. This kind of complexity 1107 // The arguments passed in caused a transition. This kind of complexity
1109 // can't be dealt with in the inlined hydrogen array constructor case. 1108 // can't be dealt with in the inlined hydrogen array constructor case.
1110 // We must mark the allocationsite as un-inlinable. 1109 // We must mark the allocationsite as un-inlinable.
1111 site->SetDoNotInlineCall(); 1110 site->SetDoNotInlineCall();
1112 } 1111 }
1113
1114 // Set up the prototoype using original function.
1115 // TODO(dslomov): instead of setting the __proto__,
1116 // use and cache the correct map.
1117 if (*original_constructor != *constructor) {
1118 if (original_constructor->has_instance_prototype()) {
1119 Handle<Object> prototype =
1120 handle(original_constructor->instance_prototype(), isolate);
1121 RETURN_FAILURE_ON_EXCEPTION(
1122 isolate, JSObject::SetPrototype(array, prototype, false));
1123 }
1124 }
1125
1126 return *array; 1112 return *array;
1127 } 1113 }
1128 1114
1129 1115
1130 RUNTIME_FUNCTION(Runtime_ArrayConstructor) { 1116 RUNTIME_FUNCTION(Runtime_ArrayConstructor) {
1131 HandleScope scope(isolate); 1117 HandleScope scope(isolate);
1132 // If we get 2 arguments then they are the stub parameters (constructor, type 1118 // If we get 2 arguments then they are the stub parameters (constructor, type
1133 // info). If we get 4, then the first one is a pointer to the arguments 1119 // info). If we get 4, then the first one is a pointer to the arguments
1134 // passed by the caller, and the last one is the length of the arguments 1120 // passed by the caller, and the last one is the length of the arguments
1135 // passed to the caller (redundant, but useful to check on the deoptimizer 1121 // passed to the caller (redundant, but useful to check on the deoptimizer
(...skipping 13 matching lines...) Expand all
1149 } 1135 }
1150 #endif 1136 #endif
1151 1137
1152 Handle<AllocationSite> site; 1138 Handle<AllocationSite> site;
1153 if (!type_info.is_null() && 1139 if (!type_info.is_null() &&
1154 *type_info != isolate->heap()->undefined_value()) { 1140 *type_info != isolate->heap()->undefined_value()) {
1155 site = Handle<AllocationSite>::cast(type_info); 1141 site = Handle<AllocationSite>::cast(type_info);
1156 DCHECK(!site->SitePointsToLiteral()); 1142 DCHECK(!site->SitePointsToLiteral());
1157 } 1143 }
1158 1144
1159 return ArrayConstructorCommon(isolate, constructor, constructor, site, 1145 return ArrayConstructorCommon(isolate, constructor, site, caller_args);
1160 caller_args);
1161 } 1146 }
1162 1147
1163 1148
1164 RUNTIME_FUNCTION(Runtime_ArrayConstructorWithSubclassing) {
1165 HandleScope scope(isolate);
1166 DCHECK(args.length() >= 2);
1167 int args_length = args.length();
1168 CHECK(args[args_length - 2]->IsJSFunction());
1169 CHECK(args[args_length - 1]->IsJSFunction());
1170 Handle<JSFunction> constructor(JSFunction::cast(args[args_length - 2]));
1171 Handle<JSFunction> original_constructor(
1172 JSFunction::cast(args[args_length - 1]));
1173 Arguments caller_args(args_length - 2, args.arguments());
1174 return ArrayConstructorCommon(isolate, constructor, original_constructor,
1175 Handle<AllocationSite>::null(), &caller_args);
1176 }
1177
1178
1179 RUNTIME_FUNCTION(Runtime_InternalArrayConstructor) { 1149 RUNTIME_FUNCTION(Runtime_InternalArrayConstructor) {
1180 HandleScope scope(isolate); 1150 HandleScope scope(isolate);
1181 Arguments empty_args(0, NULL); 1151 Arguments empty_args(0, NULL);
1182 bool no_caller_args = args.length() == 1; 1152 bool no_caller_args = args.length() == 1;
1183 DCHECK(no_caller_args || args.length() == 3); 1153 DCHECK(no_caller_args || args.length() == 3);
1184 int parameters_start = no_caller_args ? 0 : 1; 1154 int parameters_start = no_caller_args ? 0 : 1;
1185 Arguments* caller_args = 1155 Arguments* caller_args =
1186 no_caller_args ? &empty_args : reinterpret_cast<Arguments*>(args[0]); 1156 no_caller_args ? &empty_args : reinterpret_cast<Arguments*>(args[0]);
1187 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start); 1157 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start);
1188 #ifdef DEBUG 1158 #ifdef DEBUG
1189 if (!no_caller_args) { 1159 if (!no_caller_args) {
1190 CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 1); 1160 CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 1);
1191 DCHECK(arg_count == caller_args->length()); 1161 DCHECK(arg_count == caller_args->length());
1192 } 1162 }
1193 #endif 1163 #endif
1194 return ArrayConstructorCommon(isolate, constructor, constructor, 1164 return ArrayConstructorCommon(isolate, constructor,
1195 Handle<AllocationSite>::null(), caller_args); 1165 Handle<AllocationSite>::null(), caller_args);
1196 } 1166 }
1197 1167
1198 1168
1199 RUNTIME_FUNCTION(Runtime_NormalizeElements) { 1169 RUNTIME_FUNCTION(Runtime_NormalizeElements) {
1200 HandleScope scope(isolate); 1170 HandleScope scope(isolate);
1201 DCHECK(args.length() == 1); 1171 DCHECK(args.length() == 1);
1202 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); 1172 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0);
1203 RUNTIME_ASSERT(!array->HasExternalArrayElements() && 1173 RUNTIME_ASSERT(!array->HasExternalArrayElements() &&
1204 !array->HasFixedTypedArrayElements() && 1174 !array->HasFixedTypedArrayElements() &&
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 } 1310 }
1341 1311
1342 1312
1343 RUNTIME_FUNCTION(RuntimeReference_FastOneByteArrayJoin) { 1313 RUNTIME_FUNCTION(RuntimeReference_FastOneByteArrayJoin) {
1344 SealHandleScope shs(isolate); 1314 SealHandleScope shs(isolate);
1345 DCHECK(args.length() == 2); 1315 DCHECK(args.length() == 2);
1346 return isolate->heap()->undefined_value(); 1316 return isolate->heap()->undefined_value();
1347 } 1317 }
1348 } 1318 }
1349 } // namespace v8::internal 1319 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698