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

Side by Side Diff: src/builtins.cc

Issue 390323002: Remove JSReceiver::GetPrototype and replace it with PrototypeIterator calls (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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/api.cc ('k') | src/deoptimizer.cc » ('j') | src/runtime.cc » ('J')
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 // 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/api.h" 7 #include "src/api.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/base/once.h" 9 #include "src/base/once.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 247
248 248
249 static bool ArrayPrototypeHasNoElements(Heap* heap, 249 static bool ArrayPrototypeHasNoElements(Heap* heap,
250 Context* native_context, 250 Context* native_context,
251 JSObject* array_proto) { 251 JSObject* array_proto) {
252 DisallowHeapAllocation no_gc; 252 DisallowHeapAllocation no_gc;
253 // This method depends on non writability of Object and Array prototype 253 // This method depends on non writability of Object and Array prototype
254 // fields. 254 // fields.
255 if (array_proto->elements() != heap->empty_fixed_array()) return false; 255 if (array_proto->elements() != heap->empty_fixed_array()) return false;
256 // Object.prototype 256 // Object.prototype
257 Object* proto = array_proto->GetPrototype(); 257 PrototypeIterator iter(heap->isolate(), array_proto);
258 if (proto == heap->null_value()) return false; 258 if (iter.IsAtEnd()) {
259 array_proto = JSObject::cast(proto); 259 return false;
260 }
261 array_proto = JSObject::cast(iter.GetCurrent());
260 if (array_proto != native_context->initial_object_prototype()) return false; 262 if (array_proto != native_context->initial_object_prototype()) return false;
261 if (array_proto->elements() != heap->empty_fixed_array()) return false; 263 if (array_proto->elements() != heap->empty_fixed_array()) return false;
262 return array_proto->GetPrototype()->IsNull(); 264 return true;
Toon Verwaest 2014/07/16 15:41:01 We still need to check whether we are actually at
jochen (gone - plz use gerrit) 2014/07/17 06:58:02 that's handled by the check in line 258. The proto
Toon Verwaest 2014/07/17 08:00:37 No it's not, due to line 259. We are checking Obje
263 } 265 }
264 266
265 267
266 // Returns empty handle if not applicable. 268 // Returns empty handle if not applicable.
267 MUST_USE_RESULT 269 MUST_USE_RESULT
268 static inline MaybeHandle<FixedArrayBase> EnsureJSArrayWithWritableFastElements( 270 static inline MaybeHandle<FixedArrayBase> EnsureJSArrayWithWritableFastElements(
269 Isolate* isolate, 271 Isolate* isolate,
270 Handle<Object> receiver, 272 Handle<Object> receiver,
271 Arguments* args, 273 Arguments* args,
272 int first_added_arg) { 274 int first_added_arg) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 } 327 }
326 328
327 329
328 static inline bool IsJSArrayFastElementMovingAllowed(Heap* heap, 330 static inline bool IsJSArrayFastElementMovingAllowed(Heap* heap,
329 JSArray* receiver) { 331 JSArray* receiver) {
330 if (!FLAG_clever_optimizations) return false; 332 if (!FLAG_clever_optimizations) return false;
331 DisallowHeapAllocation no_gc; 333 DisallowHeapAllocation no_gc;
332 Context* native_context = heap->isolate()->context()->native_context(); 334 Context* native_context = heap->isolate()->context()->native_context();
333 JSObject* array_proto = 335 JSObject* array_proto =
334 JSObject::cast(native_context->array_function()->prototype()); 336 JSObject::cast(native_context->array_function()->prototype());
335 return receiver->GetPrototype() == array_proto && 337 PrototypeIterator iter(heap->isolate(), receiver);
338 return iter.GetCurrent() == array_proto &&
336 ArrayPrototypeHasNoElements(heap, native_context, array_proto); 339 ArrayPrototypeHasNoElements(heap, native_context, array_proto);
337 } 340 }
338 341
339 342
340 MUST_USE_RESULT static Object* CallJsBuiltin( 343 MUST_USE_RESULT static Object* CallJsBuiltin(
341 Isolate* isolate, 344 Isolate* isolate,
342 const char* name, 345 const char* name,
343 BuiltinArguments<NO_EXTRA_ARGUMENTS> args) { 346 BuiltinArguments<NO_EXTRA_ARGUMENTS> args) {
344 HandleScope handleScope(isolate); 347 HandleScope handleScope(isolate);
345 348
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 if (!ArrayPrototypeHasNoElements(heap, native_context, array_proto)) { 996 if (!ArrayPrototypeHasNoElements(heap, native_context, array_proto)) {
994 AllowHeapAllocation allow_allocation; 997 AllowHeapAllocation allow_allocation;
995 return CallJsBuiltin(isolate, "ArrayConcatJS", args); 998 return CallJsBuiltin(isolate, "ArrayConcatJS", args);
996 } 999 }
997 1000
998 // Iterate through all the arguments performing checks 1001 // Iterate through all the arguments performing checks
999 // and calculating total length. 1002 // and calculating total length.
1000 bool is_holey = false; 1003 bool is_holey = false;
1001 for (int i = 0; i < n_arguments; i++) { 1004 for (int i = 0; i < n_arguments; i++) {
1002 Object* arg = args[i]; 1005 Object* arg = args[i];
1003 if (!arg->IsJSArray() || 1006 PrototypeIterator iter(isolate, arg);
1004 !JSArray::cast(arg)->HasFastElements() || 1007 if (!arg->IsJSArray() || !JSArray::cast(arg)->HasFastElements() ||
1005 JSArray::cast(arg)->GetPrototype() != array_proto) { 1008 iter.GetCurrent() != array_proto) {
1006 AllowHeapAllocation allow_allocation; 1009 AllowHeapAllocation allow_allocation;
1007 return CallJsBuiltin(isolate, "ArrayConcatJS", args); 1010 return CallJsBuiltin(isolate, "ArrayConcatJS", args);
1008 } 1011 }
1009 int len = Smi::cast(JSArray::cast(arg)->length())->value(); 1012 int len = Smi::cast(JSArray::cast(arg)->length())->value();
1010 1013
1011 // We shouldn't overflow when adding another len. 1014 // We shouldn't overflow when adding another len.
1012 const int kHalfOfMaxInt = 1 << (kBitsPerInt - 2); 1015 const int kHalfOfMaxInt = 1 << (kBitsPerInt - 2);
1013 STATIC_ASSERT(FixedArray::kMaxLength < kHalfOfMaxInt); 1016 STATIC_ASSERT(FixedArray::kMaxLength < kHalfOfMaxInt);
1014 USE(kHalfOfMaxInt); 1017 USE(kHalfOfMaxInt);
1015 result_len += len; 1018 result_len += len;
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 } 1716 }
1714 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 1717 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
1715 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 1718 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
1716 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 1719 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
1717 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 1720 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
1718 #undef DEFINE_BUILTIN_ACCESSOR_C 1721 #undef DEFINE_BUILTIN_ACCESSOR_C
1719 #undef DEFINE_BUILTIN_ACCESSOR_A 1722 #undef DEFINE_BUILTIN_ACCESSOR_A
1720 1723
1721 1724
1722 } } // namespace v8::internal 1725 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/deoptimizer.cc » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698