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

Side by Side Diff: src/code-stubs.h

Issue 384403002: StubCallInterfaceDescriptor takes a context register. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Base class for Descriptors. 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 | « no previous file | src/code-stubs.cc » ('j') | src/hydrogen-instructions.h » ('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 #ifndef V8_CODE_STUBS_H_ 5 #ifndef V8_CODE_STUBS_H_
6 #define V8_CODE_STUBS_H_ 6 #define V8_CODE_STUBS_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/assembler.h" 9 #include "src/assembler.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 264
265 protected: 265 protected:
266 // Generates the assembler code for the stub. 266 // Generates the assembler code for the stub.
267 virtual void Generate(MacroAssembler* masm) = 0; 267 virtual void Generate(MacroAssembler* masm) = 0;
268 }; 268 };
269 269
270 270
271 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; 271 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE };
272 enum HandlerArgumentsMode { DONT_PASS_ARGUMENTS, PASS_ARGUMENTS }; 272 enum HandlerArgumentsMode { DONT_PASS_ARGUMENTS, PASS_ARGUMENTS };
273 273
274 class CodeStubInterfaceDescriptor { 274 class InterfaceDescriptor {
danno 2014/07/15 07:48:31 In general, could more stuff in this class be priv
275 public:
276 static const Register ContextRegister();
danno 2014/07/15 07:48:31 Can you make this a virtual register that returns
277
278 InterfaceDescriptor();
279 virtual ~InterfaceDescriptor() {}
280
281 bool initialized() const { return register_param_count_ >= 0; }
282
283 int environment_length() const {
danno 2014/07/15 07:48:31 Since this is not an accessor with an indentical n
mvstanton 2014/07/16 09:43:26 Done.
284 return register_param_count_;
285 }
286
287 int register_param_count() const { return register_param_count_; }
288
289 Register GetParameterRegister(int index) const {
290 return register_params_[index];
291 }
292
293 Representation GetParameterRepresentation(int index) const {
294 ASSERT(index < register_param_count_);
295 if (register_param_representations_.get() == NULL) {
296 return Representation::Tagged();
297 }
298
299 return register_param_representations_[index];
300 }
301
302 Representation* register_param_representations() const {
danno 2014/07/15 07:48:31 Does this have to be public?
mvstanton 2014/07/16 09:43:26 No, it is gone, good catch.
303 return register_param_representations_.get();
304 }
305
306 virtual bool needs_context_register() const { return true; }
danno 2014/07/15 07:48:31 NeedsContextRegister
mvstanton 2014/07/16 09:43:26 Done.
307
308 protected:
309 void Initialize(int register_parameter_count, Register* registers,
310 Representation* register_param_representations);
311
312 private:
313 int register_param_count_;
314
315 // The Register params are allocated dynamically by the
316 // CodeStubInterfaceDescriptor, and freed on destruction. This is because
317 // static arrays of Registers cause creation of runtime static initializers
318 // which we don't want.
319 SmartArrayPointer<Register> register_params_;
320 // Specifies Representations for the stub's parameter. Points to an array of
321 // Representations of the same length of the numbers of parameters to the
322 // stub, or if NULL (the default value), Representation of each parameter
323 // assumed to be Tagged().
324 SmartArrayPointer<Representation> register_param_representations_;
325 };
326
327
328 class CodeStubInterfaceDescriptor: public InterfaceDescriptor {
275 public: 329 public:
276 CodeStubInterfaceDescriptor(); 330 CodeStubInterfaceDescriptor();
277 331
278 void Initialize(int register_parameter_count, Register* registers, 332 void Initialize(int register_parameter_count, Register* registers,
279 Address deoptimization_handler = NULL, 333 Address deoptimization_handler = NULL,
280 Representation* register_param_representations = NULL, 334 Representation* register_param_representations = NULL,
281 int hint_stack_parameter_count = -1, 335 int hint_stack_parameter_count = -1,
282 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE); 336 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE);
283 void Initialize(int register_parameter_count, Register* registers, 337 void Initialize(int register_parameter_count, Register* registers,
284 Register stack_parameter_count, 338 Register stack_parameter_count,
285 Address deoptimization_handler = NULL, 339 Address deoptimization_handler = NULL,
286 Representation* register_param_representations = NULL, 340 Representation* register_param_representations = NULL,
287 int hint_stack_parameter_count = -1, 341 int hint_stack_parameter_count = -1,
288 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE, 342 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE,
289 HandlerArgumentsMode handler_mode = DONT_PASS_ARGUMENTS); 343 HandlerArgumentsMode handler_mode = DONT_PASS_ARGUMENTS);
290 bool initialized() const { return register_param_count_ >= 0; }
291
292 int environment_length() const {
293 return register_param_count_;
294 }
295 344
296 void SetMissHandler(ExternalReference handler) { 345 void SetMissHandler(ExternalReference handler) {
297 miss_handler_ = handler; 346 miss_handler_ = handler;
298 has_miss_handler_ = true; 347 has_miss_handler_ = true;
299 // Our miss handler infrastructure doesn't currently support 348 // Our miss handler infrastructure doesn't currently support
300 // variable stack parameter counts. 349 // variable stack parameter counts.
301 ASSERT(!stack_parameter_count_.is_valid()); 350 ASSERT(!stack_parameter_count_.is_valid());
302 } 351 }
303 352
304 ExternalReference miss_handler() const { 353 ExternalReference miss_handler() const {
305 ASSERT(has_miss_handler_); 354 ASSERT(has_miss_handler_);
306 return miss_handler_; 355 return miss_handler_;
307 } 356 }
308 357
309 bool has_miss_handler() const { 358 bool has_miss_handler() const {
310 return has_miss_handler_; 359 return has_miss_handler_;
311 } 360 }
312 361
313 Register GetParameterRegister(int index) const {
314 return register_params_[index];
315 }
316
317 Representation GetRegisterParameterRepresentation(int index) const {
318 ASSERT(index < register_param_count_);
319 if (register_param_representations_.get() == NULL) {
320 return Representation::Tagged();
321 }
322
323 return register_param_representations_[index];
324 }
325
326 bool IsParameterCountRegister(int index) const { 362 bool IsParameterCountRegister(int index) const {
327 return GetParameterRegister(index).is(stack_parameter_count_); 363 return GetParameterRegister(index).is(stack_parameter_count_);
328 } 364 }
329 365
330 int GetHandlerParameterCount() const { 366 int GetHandlerParameterCount() const {
331 int params = environment_length(); 367 int params = environment_length();
332 if (handler_arguments_mode_ == PASS_ARGUMENTS) { 368 if (handler_arguments_mode_ == PASS_ARGUMENTS) {
333 params += 1; 369 params += 1;
334 } 370 }
335 return params; 371 return params;
336 } 372 }
337 373
338 int register_param_count() const { return register_param_count_; }
339 int hint_stack_parameter_count() const { return hint_stack_parameter_count_; } 374 int hint_stack_parameter_count() const { return hint_stack_parameter_count_; }
340 Register stack_parameter_count() const { return stack_parameter_count_; } 375 Register stack_parameter_count() const { return stack_parameter_count_; }
341 StubFunctionMode function_mode() const { return function_mode_; } 376 StubFunctionMode function_mode() const { return function_mode_; }
342 Address deoptimization_handler() const { return deoptimization_handler_; } 377 Address deoptimization_handler() const { return deoptimization_handler_; }
343 Representation* register_param_representations() const {
344 return register_param_representations_.get();
345 }
346 378
347 private: 379 private:
348 int register_param_count_;
349
350 Register stack_parameter_count_; 380 Register stack_parameter_count_;
351 // If hint_stack_parameter_count_ > 0, the code stub can optimize the 381 // If hint_stack_parameter_count_ > 0, the code stub can optimize the
352 // return sequence. Default value is -1, which means it is ignored. 382 // return sequence. Default value is -1, which means it is ignored.
353 int hint_stack_parameter_count_; 383 int hint_stack_parameter_count_;
354 StubFunctionMode function_mode_; 384 StubFunctionMode function_mode_;
355 // The Register params are allocated dynamically by the
356 // CodeStubInterfaceDescriptor, and freed on destruction. This is because
357 // static arrays of Registers cause creation of runtime static initializers
358 // which we don't want.
359 SmartArrayPointer<Register> register_params_;
360 // Specifies Representations for the stub's parameter. Points to an array of
361 // Representations of the same length of the numbers of parameters to the
362 // stub, or if NULL (the default value), Representation of each parameter
363 // assumed to be Tagged().
364 SmartArrayPointer<Representation> register_param_representations_;
365 385
366 Address deoptimization_handler_; 386 Address deoptimization_handler_;
367 HandlerArgumentsMode handler_arguments_mode_; 387 HandlerArgumentsMode handler_arguments_mode_;
368 388
369 ExternalReference miss_handler_; 389 ExternalReference miss_handler_;
370 bool has_miss_handler_; 390 bool has_miss_handler_;
371 DISALLOW_COPY_AND_ASSIGN(CodeStubInterfaceDescriptor); 391 DISALLOW_COPY_AND_ASSIGN(CodeStubInterfaceDescriptor);
372 }; 392 };
373 393
374 394
375 class PlatformCallInterfaceDescriptor; 395 class PlatformCallInterfaceDescriptor;
376 396
377 397
378 class CallInterfaceDescriptor { 398 class CallInterfaceDescriptor: public InterfaceDescriptor {
379 public: 399 public:
380 CallInterfaceDescriptor() 400 CallInterfaceDescriptor()
381 : register_param_count_(-1), 401 : platform_specific_descriptor_(NULL) { }
382 register_params_(NULL),
383 param_representations_(NULL),
384 platform_specific_descriptor_(NULL) { }
385 402
386 // A copy of the passed in registers and param_representations is made 403 // A copy of the passed in registers and param_representations is made
387 // and owned by the CallInterfaceDescriptor. 404 // and owned by the CallInterfaceDescriptor.
388 405
389 // TODO(mvstanton): Instead of taking parallel arrays register and 406 // TODO(mvstanton): Instead of taking parallel arrays register and
390 // param_representations, how about a struct that puts the representation 407 // param_representations, how about a struct that puts the representation
391 // and register side by side (eg, RegRep(r1, Representation::Tagged()). 408 // and register side by side (eg, RegRep(r1, Representation::Tagged()).
392 // The same should go for the CodeStubInterfaceDescriptor class. 409 // The same should go for the CodeStubInterfaceDescriptor class.
393 void Initialize(int register_parameter_count, Register* registers, 410 void Initialize(int register_parameter_count, Register* registers,
394 Representation* param_representations, 411 Representation* param_representations,
395 PlatformCallInterfaceDescriptor* platform_descriptor = NULL); 412 PlatformCallInterfaceDescriptor* platform_descriptor = NULL);
396 413
397 bool initialized() const { return register_param_count_ >= 0; }
398
399 int environment_length() const {
400 return register_param_count_;
401 }
402
403 Representation GetParameterRepresentation(int index) const {
404 return param_representations_[index];
405 }
406
407 Register GetParameterRegister(int index) const {
408 return register_params_[index];
409 }
410
411 PlatformCallInterfaceDescriptor* platform_specific_descriptor() const { 414 PlatformCallInterfaceDescriptor* platform_specific_descriptor() const {
412 return platform_specific_descriptor_; 415 return platform_specific_descriptor_;
413 } 416 }
414 417
415 private: 418 private:
416 int register_param_count_; 419 int register_param_count_;
417 SmartArrayPointer<Register> register_params_;
418 SmartArrayPointer<Representation> param_representations_;
419 PlatformCallInterfaceDescriptor* platform_specific_descriptor_; 420 PlatformCallInterfaceDescriptor* platform_specific_descriptor_;
420 }; 421 };
421 422
422 423
423 class HydrogenCodeStub : public CodeStub { 424 class HydrogenCodeStub : public CodeStub {
424 public: 425 public:
425 enum InitializationState { 426 enum InitializationState {
426 UNINITIALIZED, 427 UNINITIALIZED,
427 INITIALIZED 428 INITIALIZED
428 }; 429 };
(...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2540 2541
2541 2542
2542 class CallDescriptors { 2543 class CallDescriptors {
2543 public: 2544 public:
2544 static void InitializeForIsolate(Isolate* isolate); 2545 static void InitializeForIsolate(Isolate* isolate);
2545 }; 2546 };
2546 2547
2547 } } // namespace v8::internal 2548 } } // namespace v8::internal
2548 2549
2549 #endif // V8_CODE_STUBS_H_ 2550 #endif // V8_CODE_STUBS_H_
OLDNEW
« no previous file with comments | « no previous file | src/code-stubs.cc » ('j') | src/hydrogen-instructions.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698