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

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

Issue 1292283005: Prototype CL for faster DOM accessors. Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "src/v8.h"
6
7 #include "src/arguments.h"
8 #include "src/runtime/runtime-utils.h"
9
10 // Implmement runtime functions for direct DOM element access.
11
12 namespace v8 {
13 namespace internal {
14
15 namespace {
16
17 // Helper functions & definitions to handle our 'external pointer' pseudo
18 // type. Essentially, we're using the "aligned pointer in Smi" hack to
19 // transport a C++ pointer between our intrinsics below.
20
21 #define CONVERT_PTR_ARG_CHECKED(name, index) \
22 RUNTIME_ASSERT(args[index]->IsSmi()); \
23 intptr_t name = fromObject(args.arguments()[index]);
24
25 typedef intptr_t aligned_ptr_t;
26
27
28 static aligned_ptr_t fromObject(Object* value) {
29 DCHECK(value->IsSmi());
30 return *reinterpret_cast<aligned_ptr_t*>(&value);
epertoso 2015/09/25 08:22:53 just return reinterpret_cast<aligned_ptr>(value).
vogelheim 2015/09/29 11:15:17 Done. For some reason, I was dead sure that you c
31 }
32
33
34 static Object* fromAlignedPtr(aligned_ptr_t value) {
35 Object* object = *reinterpret_cast<Object**>(&value);
epertoso 2015/09/25 08:22:53 As above, just reinterpret_cast<Object*>(value) is
vogelheim 2015/09/29 11:15:17 Done.
36 DCHECK(object->IsSmi());
37 return object;
38 }
39
40
41 static aligned_ptr_t loadAsPtr(aligned_ptr_t value) {
42 return *reinterpret_cast<aligned_ptr_t*>(value);
43 }
44
45
46 static int32_t loadAsInt32(aligned_ptr_t value) {
47 return *reinterpret_cast<int32_t*>(value);
48 }
49
50
51 static void checkAlignedOffset(int offset) { DCHECK((offset % 4) == 0); }
52
53
54 static Object* objectFromAlignedPtr(aligned_ptr_t value) {
55 Object* object = *reinterpret_cast<Object**>(&value);
epertoso 2015/09/25 08:22:53 And here too :).
vogelheim 2015/09/29 11:15:17 Done.
56 DCHECK(!object->IsSmi());
57 return object;
58 }
59
60 } // anonymous namespace
61
62
63 RUNTIME_FUNCTION(Runtime_PtrGetFromInternalField) {
64 HandleScope scope(isolate);
epertoso 2015/09/25 08:22:53 I think is that these functions should be UNREACHA
vogelheim 2015/09/29 11:15:17 Disagree. The reason why I want them (#ifdef-ed) i
65 DCHECK(args.length() == 2);
66 CONVERT_ARG_HANDLE_CHECKED(JSObject, wrapper, 0);
67 CONVERT_SMI_ARG_CHECKED(field_number, 1);
68 Object* object = wrapper->GetInternalField(field_number);
69 DCHECK(object->IsSmi());
70 return object;
71 }
72
73
74 RUNTIME_FUNCTION(Runtime_PtrLoadOffset) {
75 HandleScope scope(isolate);
76 DCHECK(args.length() == 2);
77 CONVERT_PTR_ARG_CHECKED(ptr, 0);
78 CONVERT_SMI_ARG_CHECKED(offset, 1);
79 checkAlignedOffset(offset);
80 return fromAlignedPtr(loadAsPtr(ptr + offset));
81 }
82
83
84 RUNTIME_FUNCTION(Runtime_PtrLoadOffsetInt) {
jochen (gone - plz use gerrit) 2015/09/25 11:20:12 why not PtrTestIntAtOffset() or something?
vogelheim 2015/09/29 11:15:17 Meanwhile, Enrico has done a good bit of work with
85 HandleScope scope(isolate);
86 DCHECK(args.length() == 2);
87 CONVERT_PTR_ARG_CHECKED(ptr, 0);
88 CONVERT_SMI_ARG_CHECKED(offset, 1);
89 checkAlignedOffset(offset);
90 return Smi::FromInt(loadAsInt32(ptr + offset));
91 }
92
93
94 RUNTIME_FUNCTION(Runtime_PtrLoadOffsetObj) {
95 HandleScope scope(isolate);
96 DCHECK(args.length() == 1);
97 CONVERT_PTR_ARG_CHECKED(ptr, 0);
98 return objectFromAlignedPtr(loadAsPtr(ptr));
99 }
100
101
102 RUNTIME_FUNCTION(Runtime_PtrIsNull) {
103 HandleScope scope(isolate);
104 DCHECK(args.length() == 1);
105 CONVERT_PTR_ARG_CHECKED(ptr, 0);
106 return (ptr == 0) ? isolate->heap()->true_value()
107 : isolate->heap()->false_value();
108 }
109
110 } // namespace internal
111 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698