OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 Scope* scope, | 315 Scope* scope, |
316 Handle<JSFunction> closure); | 316 Handle<JSFunction> closure); |
317 | 317 |
318 // Simple accessors. | 318 // Simple accessors. |
319 Handle<JSFunction> closure() const { return closure_; } | 319 Handle<JSFunction> closure() const { return closure_; } |
320 const ZoneList<HValue*>* values() const { return &values_; } | 320 const ZoneList<HValue*>* values() const { return &values_; } |
321 const ZoneList<int>* assigned_variables() const { | 321 const ZoneList<int>* assigned_variables() const { |
322 return &assigned_variables_; | 322 return &assigned_variables_; |
323 } | 323 } |
324 int parameter_count() const { return parameter_count_; } | 324 int parameter_count() const { return parameter_count_; } |
325 int specials_count() const { return specials_count_; } | |
325 int local_count() const { return local_count_; } | 326 int local_count() const { return local_count_; } |
326 HEnvironment* outer() const { return outer_; } | 327 HEnvironment* outer() const { return outer_; } |
327 int pop_count() const { return pop_count_; } | 328 int pop_count() const { return pop_count_; } |
328 int push_count() const { return push_count_; } | 329 int push_count() const { return push_count_; } |
329 | 330 |
330 int ast_id() const { return ast_id_; } | 331 int ast_id() const { return ast_id_; } |
331 void set_ast_id(int id) { ast_id_ = id; } | 332 void set_ast_id(int id) { ast_id_ = id; } |
332 | 333 |
333 int length() const { return values_.length(); } | 334 int length() const { return values_.length(); } |
335 bool is_special_index(int i) const { | |
336 return i >= parameter_count() && i < parameter_count() + specials_count(); | |
337 } | |
334 | 338 |
335 void Bind(Variable* variable, HValue* value) { | 339 void Bind(Variable* variable, HValue* value) { |
336 Bind(IndexFor(variable), value); | 340 Bind(IndexFor(variable), value); |
337 } | 341 } |
338 | 342 |
339 void Bind(int index, HValue* value); | 343 void Bind(int index, HValue* value); |
340 | 344 |
341 HValue* Lookup(Variable* variable) const { | 345 HValue* Lookup(Variable* variable) const { |
342 return Lookup(IndexFor(variable)); | 346 return Lookup(IndexFor(variable)); |
343 } | 347 } |
344 | 348 |
345 HValue* Lookup(int index) const { | 349 HValue* Lookup(int index) const { |
346 HValue* result = values_[index]; | 350 HValue* result = values_[index]; |
347 ASSERT(result != NULL); | 351 ASSERT(result != NULL); |
348 return result; | 352 return result; |
349 } | 353 } |
350 | 354 |
355 HValue* LookupContext() const { | |
Kevin Millikin (Chromium)
2011/05/06 12:29:45
Probably should have a BindContext function too, s
| |
356 // Return first special. | |
357 return Lookup(parameter_count()); | |
358 } | |
359 | |
351 void Push(HValue* value) { | 360 void Push(HValue* value) { |
352 ASSERT(value != NULL); | 361 ASSERT(value != NULL); |
353 ++push_count_; | 362 ++push_count_; |
354 values_.Add(value); | 363 values_.Add(value); |
355 } | 364 } |
356 | 365 |
357 HValue* Pop() { | 366 HValue* Pop() { |
358 ASSERT(!ExpressionStackIsEmpty()); | 367 ASSERT(!ExpressionStackIsEmpty()); |
359 if (push_count_ > 0) { | 368 if (push_count_ > 0) { |
360 --push_count_; | 369 --push_count_; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
416 | 425 |
417 void Initialize(int parameter_count, int local_count, int stack_height); | 426 void Initialize(int parameter_count, int local_count, int stack_height); |
418 void Initialize(const HEnvironment* other); | 427 void Initialize(const HEnvironment* other); |
419 | 428 |
420 // Map a variable to an environment index. Parameter indices are shifted | 429 // Map a variable to an environment index. Parameter indices are shifted |
421 // by 1 (receiver is parameter index -1 but environment index 0). | 430 // by 1 (receiver is parameter index -1 but environment index 0). |
422 // Stack-allocated local indices are shifted by the number of parameters. | 431 // Stack-allocated local indices are shifted by the number of parameters. |
423 int IndexFor(Variable* variable) const { | 432 int IndexFor(Variable* variable) const { |
424 Slot* slot = variable->AsSlot(); | 433 Slot* slot = variable->AsSlot(); |
425 ASSERT(slot != NULL && slot->IsStackAllocated()); | 434 ASSERT(slot != NULL && slot->IsStackAllocated()); |
426 int shift = (slot->type() == Slot::PARAMETER) ? 1 : parameter_count_; | 435 int shift = (slot->type() == Slot::PARAMETER) |
436 ? 1 | |
437 : parameter_count_ + specials_count_; | |
427 return slot->index() + shift; | 438 return slot->index() + shift; |
428 } | 439 } |
429 | 440 |
430 Handle<JSFunction> closure_; | 441 Handle<JSFunction> closure_; |
431 // Value array [parameters] [locals] [temporaries]. | 442 // Value array [parameters] [specials] [locals] [temporaries]. |
432 ZoneList<HValue*> values_; | 443 ZoneList<HValue*> values_; |
433 ZoneList<int> assigned_variables_; | 444 ZoneList<int> assigned_variables_; |
434 int parameter_count_; | 445 int parameter_count_; |
446 int specials_count_; | |
435 int local_count_; | 447 int local_count_; |
436 HEnvironment* outer_; | 448 HEnvironment* outer_; |
437 int pop_count_; | 449 int pop_count_; |
438 int push_count_; | 450 int push_count_; |
439 int ast_id_; | 451 int ast_id_; |
440 }; | 452 }; |
441 | 453 |
442 | 454 |
443 class HGraphBuilder; | 455 class HGraphBuilder; |
444 | 456 |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1158 const char* filename_; | 1170 const char* filename_; |
1159 HeapStringAllocator string_allocator_; | 1171 HeapStringAllocator string_allocator_; |
1160 StringStream trace_; | 1172 StringStream trace_; |
1161 int indent_; | 1173 int indent_; |
1162 }; | 1174 }; |
1163 | 1175 |
1164 | 1176 |
1165 } } // namespace v8::internal | 1177 } } // namespace v8::internal |
1166 | 1178 |
1167 #endif // V8_HYDROGEN_H_ | 1179 #endif // V8_HYDROGEN_H_ |
OLD | NEW |