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/runtime/runtime-forin.cc

Issue 1306043003: Move runtime helper for ToName conversion onto Object. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_cleanup-heap-friends
Patch Set: Minor fixup. Created 5 years, 3 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-classes.cc ('k') | src/runtime/runtime-object.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/objects-inl.h" 8 #include "src/objects-inl.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 10 matching lines...) Expand all
21 } 21 }
22 22
23 23
24 RUNTIME_FUNCTION(Runtime_ForInFilter) { 24 RUNTIME_FUNCTION(Runtime_ForInFilter) {
25 HandleScope scope(isolate); 25 HandleScope scope(isolate);
26 DCHECK_EQ(2, args.length()); 26 DCHECK_EQ(2, args.length());
27 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); 27 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
28 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 28 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
29 // TODO(turbofan): Fast case for array indices. 29 // TODO(turbofan): Fast case for array indices.
30 Handle<Name> name; 30 Handle<Name> name;
31 if (!Runtime::ToName(isolate, key).ToHandle(&name)) { 31 if (!Object::ToName(isolate, key).ToHandle(&name)) {
32 return isolate->heap()->exception(); 32 return isolate->heap()->exception();
33 } 33 }
34 Maybe<bool> result = JSReceiver::HasProperty(receiver, name); 34 Maybe<bool> result = JSReceiver::HasProperty(receiver, name);
35 if (!result.IsJust()) return isolate->heap()->exception(); 35 if (!result.IsJust()) return isolate->heap()->exception();
36 if (result.FromJust()) return *name; 36 if (result.FromJust()) return *name;
37 return isolate->heap()->undefined_value(); 37 return isolate->heap()->undefined_value();
38 } 38 }
39 39
40 40
41 RUNTIME_FUNCTION(Runtime_ForInNext) { 41 RUNTIME_FUNCTION(Runtime_ForInNext) {
42 HandleScope scope(isolate); 42 HandleScope scope(isolate);
43 DCHECK_EQ(4, args.length()); 43 DCHECK_EQ(4, args.length());
44 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); 44 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
45 CONVERT_ARG_HANDLE_CHECKED(FixedArray, cache_array, 1); 45 CONVERT_ARG_HANDLE_CHECKED(FixedArray, cache_array, 1);
46 CONVERT_ARG_HANDLE_CHECKED(Object, cache_type, 2); 46 CONVERT_ARG_HANDLE_CHECKED(Object, cache_type, 2);
47 CONVERT_SMI_ARG_CHECKED(index, 3); 47 CONVERT_SMI_ARG_CHECKED(index, 3);
48 Handle<Object> key = handle(cache_array->get(index), isolate); 48 Handle<Object> key = handle(cache_array->get(index), isolate);
49 // Don't need filtering if expected map still matches that of the receiver, 49 // Don't need filtering if expected map still matches that of the receiver,
50 // and neither for proxies. 50 // and neither for proxies.
51 if (receiver->map() == *cache_type || *cache_type == Smi::FromInt(0)) { 51 if (receiver->map() == *cache_type || *cache_type == Smi::FromInt(0)) {
52 return *key; 52 return *key;
53 } 53 }
54 // TODO(turbofan): Fast case for array indices. 54 // TODO(turbofan): Fast case for array indices.
55 Handle<Name> name; 55 Handle<Name> name;
56 if (!Runtime::ToName(isolate, key).ToHandle(&name)) { 56 if (!Object::ToName(isolate, key).ToHandle(&name)) {
57 return isolate->heap()->exception(); 57 return isolate->heap()->exception();
58 } 58 }
59 Maybe<bool> result = JSReceiver::HasProperty(receiver, name); 59 Maybe<bool> result = JSReceiver::HasProperty(receiver, name);
60 if (!result.IsJust()) return isolate->heap()->exception(); 60 if (!result.IsJust()) return isolate->heap()->exception();
61 if (result.FromJust()) return *name; 61 if (result.FromJust()) return *name;
62 return isolate->heap()->undefined_value(); 62 return isolate->heap()->undefined_value();
63 } 63 }
64 64
65 65
66 RUNTIME_FUNCTION(Runtime_ForInStep) { 66 RUNTIME_FUNCTION(Runtime_ForInStep) {
67 SealHandleScope scope(isolate); 67 SealHandleScope scope(isolate);
68 DCHECK_EQ(1, args.length()); 68 DCHECK_EQ(1, args.length());
69 CONVERT_SMI_ARG_CHECKED(index, 0); 69 CONVERT_SMI_ARG_CHECKED(index, 0);
70 DCHECK_LE(0, index); 70 DCHECK_LE(0, index);
71 DCHECK_LT(index, Smi::kMaxValue); 71 DCHECK_LT(index, Smi::kMaxValue);
72 return Smi::FromInt(index + 1); 72 return Smi::FromInt(index + 1);
73 } 73 }
74 74
75 } // namespace internal 75 } // namespace internal
76 } // namespace v8 76 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-classes.cc ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698