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

Side by Side Diff: src/arguments.h

Issue 314123003: Field layout in class Arguments is incompatible w\ 64-bit archs. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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 | « no previous file | no next file » | no next file with comments »
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 #ifndef V8_ARGUMENTS_H_ 5 #ifndef V8_ARGUMENTS_H_
6 #define V8_ARGUMENTS_H_ 6 #define V8_ARGUMENTS_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 12
13 // Arguments provides access to runtime call parameters. 13 // Arguments provides access to runtime call parameters.
14 // 14 //
15 // It uses the fact that the instance fields of Arguments 15 // It uses the fact that the instance fields of Arguments
16 // (length_, arguments_) are "overlayed" with the parameters 16 // (length_, arguments_) are "overlayed" with the parameters
17 // (no. of parameters, and the parameter pointer) passed so 17 // (no. of parameters, and the parameter pointer) passed so
18 // that inside the C++ function, the parameters passed can 18 // that inside the C++ function, the parameters passed can
19 // be accessed conveniently: 19 // be accessed conveniently:
20 // 20 //
21 // Object* Runtime_function(Arguments args) { 21 // Object* Runtime_function(Arguments args) {
22 // ... use args[i] here ... 22 // ... use args[i] here ...
23 // } 23 // }
24 //
25 // Note that length_ (whose value is in the integer range) is defined
26 // as intptr_t to provide endian-neutrality on 64-bit archs.
24 27
25 class Arguments BASE_EMBEDDED { 28 class Arguments BASE_EMBEDDED {
26 public: 29 public:
27 Arguments(int length, Object** arguments) 30 Arguments(int length, Object** arguments)
28 : length_(length), arguments_(arguments) { } 31 : length_(length), arguments_(arguments) { }
29 32
30 Object*& operator[] (int index) { 33 Object*& operator[] (int index) {
31 ASSERT(0 <= index && index < length_); 34 ASSERT(0 <= index && index < length_);
32 return *(reinterpret_cast<Object**>(reinterpret_cast<intptr_t>(arguments_) - 35 return *(reinterpret_cast<Object**>(reinterpret_cast<intptr_t>(arguments_) -
33 index * kPointerSize)); 36 index * kPointerSize));
34 } 37 }
35 38
36 template <class S> Handle<S> at(int index) { 39 template <class S> Handle<S> at(int index) {
37 Object** value = &((*this)[index]); 40 Object** value = &((*this)[index]);
38 // This cast checks that the object we're accessing does indeed have the 41 // This cast checks that the object we're accessing does indeed have the
39 // expected type. 42 // expected type.
40 S::cast(*value); 43 S::cast(*value);
41 return Handle<S>(reinterpret_cast<S**>(value)); 44 return Handle<S>(reinterpret_cast<S**>(value));
42 } 45 }
43 46
44 int smi_at(int index) { 47 int smi_at(int index) {
45 return Smi::cast((*this)[index])->value(); 48 return Smi::cast((*this)[index])->value();
46 } 49 }
47 50
48 double number_at(int index) { 51 double number_at(int index) {
49 return (*this)[index]->Number(); 52 return (*this)[index]->Number();
50 } 53 }
51 54
52 // Get the total number of arguments including the receiver. 55 // Get the total number of arguments including the receiver.
53 int length() const { return length_; } 56 int length() const { return static_cast<int>(length_); }
54 57
55 Object** arguments() { return arguments_; } 58 Object** arguments() { return arguments_; }
56 59
57 private: 60 private:
58 int length_; 61 intptr_t length_;
59 Object** arguments_; 62 Object** arguments_;
60 }; 63 };
61 64
62 65
63 // For each type of callback, we have a list of arguments 66 // For each type of callback, we have a list of arguments
64 // They are used to generate the Call() functions below 67 // They are used to generate the Call() functions below
65 // These aren't included in the list as they have duplicate signatures 68 // These aren't included in the list as they have duplicate signatures
66 // F(NamedPropertyEnumeratorCallback, ...) 69 // F(NamedPropertyEnumeratorCallback, ...)
67 // F(NamedPropertyGetterCallback, ...) 70 // F(NamedPropertyGetterCallback, ...)
68 71
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 #define RUNTIME_FUNCTION(Name) RUNTIME_FUNCTION_RETURNS_TYPE(Object*, Name) 295 #define RUNTIME_FUNCTION(Name) RUNTIME_FUNCTION_RETURNS_TYPE(Object*, Name)
293 #define RUNTIME_FUNCTION_RETURN_PAIR(Name) \ 296 #define RUNTIME_FUNCTION_RETURN_PAIR(Name) \
294 RUNTIME_FUNCTION_RETURNS_TYPE(ObjectPair, Name) 297 RUNTIME_FUNCTION_RETURNS_TYPE(ObjectPair, Name)
295 298
296 #define RUNTIME_ARGUMENTS(isolate, args) \ 299 #define RUNTIME_ARGUMENTS(isolate, args) \
297 args.length(), args.arguments(), isolate 300 args.length(), args.arguments(), isolate
298 301
299 } } // namespace v8::internal 302 } } // namespace v8::internal
300 303
301 #endif // V8_ARGUMENTS_H_ 304 #endif // V8_ARGUMENTS_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698