blob: 8864c95a6f30ac3899ebc6017a3241768df63e55 [file] [log] [blame]
Steve Blocka7e24c12009-10-30 11:49:00 +00001// Copyright 2009 the V8 project authors. All rights reserved.
2// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28#include "v8.h"
29
30#include "bootstrapper.h"
31#include "codegen-inl.h"
Steve Blockd0582a62009-12-15 09:54:21 +000032#include "compiler.h"
Steve Blocka7e24c12009-10-30 11:49:00 +000033#include "debug.h"
34#include "oprofile-agent.h"
35#include "prettyprinter.h"
36#include "register-allocator-inl.h"
37#include "rewriter.h"
38#include "runtime.h"
39#include "scopeinfo.h"
40#include "stub-cache.h"
Steve Block6ded16b2010-05-10 14:33:55 +010041#include "virtual-frame-inl.h"
Steve Blocka7e24c12009-10-30 11:49:00 +000042
43namespace v8 {
44namespace internal {
45
Andrei Popescu31002712010-02-23 13:46:05 +000046#define __ ACCESS_MASM(masm_)
47
48#ifdef DEBUG
49
50Comment::Comment(MacroAssembler* masm, const char* msg)
51 : masm_(masm), msg_(msg) {
52 __ RecordComment(msg);
53}
54
55
56Comment::~Comment() {
57 if (msg_[0] == '[') __ RecordComment("]");
58}
59
60#endif // DEBUG
61
62#undef __
63
Steve Blocka7e24c12009-10-30 11:49:00 +000064
65CodeGenerator* CodeGeneratorScope::top_ = NULL;
66
67
Steve Blocka7e24c12009-10-30 11:49:00 +000068void CodeGenerator::ProcessDeferred() {
69 while (!deferred_.is_empty()) {
70 DeferredCode* code = deferred_.RemoveLast();
71 ASSERT(masm_ == code->masm());
72 // Record position of deferred code stub.
73 masm_->RecordStatementPosition(code->statement_position());
74 if (code->position() != RelocInfo::kNoPosition) {
75 masm_->RecordPosition(code->position());
76 }
77 // Generate the code.
78 Comment cmnt(masm_, code->comment());
79 masm_->bind(code->entry_label());
80 code->SaveRegisters();
81 code->Generate();
82 code->RestoreRegisters();
83 masm_->jmp(code->exit_label());
84 }
85}
86
87
88void CodeGenerator::SetFrame(VirtualFrame* new_frame,
89 RegisterFile* non_frame_registers) {
90 RegisterFile saved_counts;
91 if (has_valid_frame()) {
92 frame_->DetachFromCodeGenerator();
93 // The remaining register reference counts are the non-frame ones.
94 allocator_->SaveTo(&saved_counts);
95 }
96
97 if (new_frame != NULL) {
98 // Restore the non-frame register references that go with the new frame.
99 allocator_->RestoreFrom(non_frame_registers);
100 new_frame->AttachToCodeGenerator();
101 }
102
103 frame_ = new_frame;
104 saved_counts.CopyTo(non_frame_registers);
105}
106
107
108void CodeGenerator::DeleteFrame() {
109 if (has_valid_frame()) {
110 frame_->DetachFromCodeGenerator();
111 frame_ = NULL;
112 }
113}
114
115
Andrei Popescu31002712010-02-23 13:46:05 +0000116void CodeGenerator::MakeCodePrologue(CompilationInfo* info) {
Steve Blocka7e24c12009-10-30 11:49:00 +0000117#ifdef DEBUG
118 bool print_source = false;
119 bool print_ast = false;
Steve Block3ce2e202009-11-05 08:53:23 +0000120 bool print_json_ast = false;
Steve Blocka7e24c12009-10-30 11:49:00 +0000121 const char* ftype;
122
123 if (Bootstrapper::IsActive()) {
124 print_source = FLAG_print_builtin_source;
125 print_ast = FLAG_print_builtin_ast;
Steve Block3ce2e202009-11-05 08:53:23 +0000126 print_json_ast = FLAG_print_builtin_json_ast;
Steve Blocka7e24c12009-10-30 11:49:00 +0000127 ftype = "builtin";
128 } else {
129 print_source = FLAG_print_source;
130 print_ast = FLAG_print_ast;
Steve Block3ce2e202009-11-05 08:53:23 +0000131 print_json_ast = FLAG_print_json_ast;
Steve Blocka7e24c12009-10-30 11:49:00 +0000132 ftype = "user-defined";
133 }
134
135 if (FLAG_trace_codegen || print_source || print_ast) {
136 PrintF("*** Generate code for %s function: ", ftype);
Andrei Popescu31002712010-02-23 13:46:05 +0000137 info->function()->name()->ShortPrint();
Steve Blocka7e24c12009-10-30 11:49:00 +0000138 PrintF(" ***\n");
139 }
140
141 if (print_source) {
Andrei Popescu31002712010-02-23 13:46:05 +0000142 PrintF("--- Source from AST ---\n%s\n",
143 PrettyPrinter().PrintProgram(info->function()));
Steve Blocka7e24c12009-10-30 11:49:00 +0000144 }
145
146 if (print_ast) {
Andrei Popescu31002712010-02-23 13:46:05 +0000147 PrintF("--- AST ---\n%s\n",
148 AstPrinter().PrintProgram(info->function()));
Steve Block3ce2e202009-11-05 08:53:23 +0000149 }
150
151 if (print_json_ast) {
152 JsonAstBuilder builder;
Andrei Popescu31002712010-02-23 13:46:05 +0000153 PrintF("%s", builder.BuildProgram(info->function()));
Steve Blocka7e24c12009-10-30 11:49:00 +0000154 }
155#endif // DEBUG
Steve Block3ce2e202009-11-05 08:53:23 +0000156}
Steve Blocka7e24c12009-10-30 11:49:00 +0000157
Steve Blocka7e24c12009-10-30 11:49:00 +0000158
Andrei Popescu31002712010-02-23 13:46:05 +0000159Handle<Code> CodeGenerator::MakeCodeEpilogue(MacroAssembler* masm,
Steve Block3ce2e202009-11-05 08:53:23 +0000160 Code::Flags flags,
Andrei Popescu31002712010-02-23 13:46:05 +0000161 CompilationInfo* info) {
Steve Block3ce2e202009-11-05 08:53:23 +0000162 // Allocate and install the code.
Steve Blocka7e24c12009-10-30 11:49:00 +0000163 CodeDesc desc;
Steve Block3ce2e202009-11-05 08:53:23 +0000164 masm->GetCode(&desc);
Andrei Popescu31002712010-02-23 13:46:05 +0000165 ZoneScopeInfo sinfo(info->scope());
Steve Block3ce2e202009-11-05 08:53:23 +0000166 Handle<Code> code =
167 Factory::NewCode(desc, &sinfo, flags, masm->CodeObject());
Steve Blocka7e24c12009-10-30 11:49:00 +0000168
Steve Blocka7e24c12009-10-30 11:49:00 +0000169#ifdef ENABLE_DISASSEMBLER
Steve Block3ce2e202009-11-05 08:53:23 +0000170 bool print_code = Bootstrapper::IsActive()
171 ? FLAG_print_builtin_code
172 : FLAG_print_code;
Steve Blocka7e24c12009-10-30 11:49:00 +0000173 if (print_code) {
174 // Print the source code if available.
Andrei Popescu31002712010-02-23 13:46:05 +0000175 Handle<Script> script = info->script();
176 FunctionLiteral* function = info->function();
Steve Blocka7e24c12009-10-30 11:49:00 +0000177 if (!script->IsUndefined() && !script->source()->IsUndefined()) {
178 PrintF("--- Raw source ---\n");
179 StringInputBuffer stream(String::cast(script->source()));
Andrei Popescu31002712010-02-23 13:46:05 +0000180 stream.Seek(function->start_position());
Steve Block3ce2e202009-11-05 08:53:23 +0000181 // fun->end_position() points to the last character in the stream. We
Steve Blocka7e24c12009-10-30 11:49:00 +0000182 // need to compensate by adding one to calculate the length.
Andrei Popescu31002712010-02-23 13:46:05 +0000183 int source_len =
184 function->end_position() - function->start_position() + 1;
Steve Blocka7e24c12009-10-30 11:49:00 +0000185 for (int i = 0; i < source_len; i++) {
186 if (stream.has_more()) PrintF("%c", stream.GetNext());
187 }
188 PrintF("\n\n");
189 }
190 PrintF("--- Code ---\n");
Andrei Popescu31002712010-02-23 13:46:05 +0000191 code->Disassemble(*function->name()->ToCString());
Steve Blocka7e24c12009-10-30 11:49:00 +0000192 }
193#endif // ENABLE_DISASSEMBLER
194
195 if (!code.is_null()) {
196 Counters::total_compiled_code_size.Increment(code->instruction_size());
197 }
Steve Blocka7e24c12009-10-30 11:49:00 +0000198 return code;
199}
200
201
Steve Block3ce2e202009-11-05 08:53:23 +0000202// Generate the code. Takes a function literal, generates code for it, assemble
203// all the pieces into a Code object. This function is only to be called by
204// the compiler.cc code.
Andrei Popescu31002712010-02-23 13:46:05 +0000205Handle<Code> CodeGenerator::MakeCode(CompilationInfo* info) {
206 Handle<Script> script = info->script();
Leon Clarked91b9f72010-01-27 17:25:45 +0000207 if (!script->IsUndefined() && !script->source()->IsUndefined()) {
208 int len = String::cast(script->source())->length();
209 Counters::total_old_codegen_source_size.Increment(len);
210 }
Andrei Popescu31002712010-02-23 13:46:05 +0000211 MakeCodePrologue(info);
Steve Block3ce2e202009-11-05 08:53:23 +0000212 // Generate code.
213 const int kInitialBufferSize = 4 * KB;
Leon Clarke4515c472010-02-03 11:58:03 +0000214 MacroAssembler masm(NULL, kInitialBufferSize);
Andrei Popescu31002712010-02-23 13:46:05 +0000215 CodeGenerator cgen(&masm);
Steve Block3ce2e202009-11-05 08:53:23 +0000216 CodeGeneratorScope scope(&cgen);
Andrei Popescu402d9372010-02-26 13:31:12 +0000217 cgen.Generate(info);
Steve Block3ce2e202009-11-05 08:53:23 +0000218 if (cgen.HasStackOverflow()) {
219 ASSERT(!Top::has_pending_exception());
220 return Handle<Code>::null();
221 }
222
223 InLoopFlag in_loop = (cgen.loop_nesting() != 0) ? IN_LOOP : NOT_IN_LOOP;
224 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION, in_loop);
Steve Block6ded16b2010-05-10 14:33:55 +0100225 return MakeCodeEpilogue(cgen.masm(), flags, info);
Steve Block3ce2e202009-11-05 08:53:23 +0000226}
227
228
Steve Blocka7e24c12009-10-30 11:49:00 +0000229#ifdef ENABLE_LOGGING_AND_PROFILING
230
231bool CodeGenerator::ShouldGenerateLog(Expression* type) {
232 ASSERT(type != NULL);
Steve Block6ded16b2010-05-10 14:33:55 +0100233 if (!Logger::is_logging() && !CpuProfiler::is_profiling()) return false;
Steve Blocka7e24c12009-10-30 11:49:00 +0000234 Handle<String> name = Handle<String>::cast(type->AsLiteral()->handle());
235 if (FLAG_log_regexp) {
236 static Vector<const char> kRegexp = CStrVector("regexp");
237 if (name->IsEqualTo(kRegexp))
238 return true;
239 }
240 return false;
241}
242
243#endif
244
245
Steve Blocka7e24c12009-10-30 11:49:00 +0000246Handle<Code> CodeGenerator::ComputeCallInitialize(
247 int argc,
248 InLoopFlag in_loop) {
249 if (in_loop == IN_LOOP) {
250 // Force the creation of the corresponding stub outside loops,
251 // because it may be used when clearing the ICs later - it is
252 // possible for a series of IC transitions to lose the in-loop
253 // information, and the IC clearing code can't generate a stub
254 // that it needs so we need to ensure it is generated already.
255 ComputeCallInitialize(argc, NOT_IN_LOOP);
256 }
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100257 CALL_HEAP_FUNCTION(
258 StubCache::ComputeCallInitialize(argc, in_loop, Code::CALL_IC),
259 Code);
Steve Blocka7e24c12009-10-30 11:49:00 +0000260}
261
262
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100263Handle<Code> CodeGenerator::ComputeKeyedCallInitialize(
264 int argc,
265 InLoopFlag in_loop) {
266 if (in_loop == IN_LOOP) {
267 // Force the creation of the corresponding stub outside loops,
268 // because it may be used when clearing the ICs later - it is
269 // possible for a series of IC transitions to lose the in-loop
270 // information, and the IC clearing code can't generate a stub
271 // that it needs so we need to ensure it is generated already.
272 ComputeKeyedCallInitialize(argc, NOT_IN_LOOP);
273 }
274 CALL_HEAP_FUNCTION(
275 StubCache::ComputeCallInitialize(argc, in_loop, Code::KEYED_CALL_IC),
276 Code);
277}
278
Steve Blocka7e24c12009-10-30 11:49:00 +0000279void CodeGenerator::ProcessDeclarations(ZoneList<Declaration*>* declarations) {
280 int length = declarations->length();
281 int globals = 0;
282 for (int i = 0; i < length; i++) {
283 Declaration* node = declarations->at(i);
284 Variable* var = node->proxy()->var();
285 Slot* slot = var->slot();
286
287 // If it was not possible to allocate the variable at compile
288 // time, we need to "declare" it at runtime to make sure it
289 // actually exists in the local context.
290 if ((slot != NULL && slot->type() == Slot::LOOKUP) || !var->is_global()) {
291 VisitDeclaration(node);
292 } else {
293 // Count global variables and functions for later processing
294 globals++;
295 }
296 }
297
298 // Return in case of no declared global functions or variables.
299 if (globals == 0) return;
300
301 // Compute array of global variable and function declarations.
302 Handle<FixedArray> array = Factory::NewFixedArray(2 * globals, TENURED);
303 for (int j = 0, i = 0; i < length; i++) {
304 Declaration* node = declarations->at(i);
305 Variable* var = node->proxy()->var();
306 Slot* slot = var->slot();
307
308 if ((slot != NULL && slot->type() == Slot::LOOKUP) || !var->is_global()) {
309 // Skip - already processed.
310 } else {
311 array->set(j++, *(var->name()));
312 if (node->fun() == NULL) {
313 if (var->mode() == Variable::CONST) {
314 // In case this is const property use the hole.
315 array->set_the_hole(j++);
316 } else {
317 array->set_undefined(j++);
318 }
319 } else {
Steve Block6ded16b2010-05-10 14:33:55 +0100320 Handle<SharedFunctionInfo> function =
321 Compiler::BuildFunctionInfo(node->fun(), script(), this);
Steve Blocka7e24c12009-10-30 11:49:00 +0000322 // Check for stack-overflow exception.
323 if (HasStackOverflow()) return;
324 array->set(j++, *function);
325 }
326 }
327 }
328
329 // Invoke the platform-dependent code generator to do the actual
330 // declaration the global variables and functions.
331 DeclareGlobals(array);
332}
333
334
Steve Block6ded16b2010-05-10 14:33:55 +0100335// List of special runtime calls which are generated inline. For some of these
336// functions the code will be generated inline, and for others a call to a code
337// stub will be inlined.
Steve Blocka7e24c12009-10-30 11:49:00 +0000338
Steve Block6ded16b2010-05-10 14:33:55 +0100339#define INLINE_RUNTIME_ENTRY(Name, argc, ressize) \
340 {&CodeGenerator::Generate##Name, "_" #Name, argc}, \
341
Steve Blocka7e24c12009-10-30 11:49:00 +0000342CodeGenerator::InlineRuntimeLUT CodeGenerator::kInlineRuntimeLUT[] = {
Steve Block6ded16b2010-05-10 14:33:55 +0100343 INLINE_RUNTIME_FUNCTION_LIST(INLINE_RUNTIME_ENTRY)
Steve Blocka7e24c12009-10-30 11:49:00 +0000344};
345
Steve Block6ded16b2010-05-10 14:33:55 +0100346#undef INLINE_RUNTIME_ENTRY
Steve Blocka7e24c12009-10-30 11:49:00 +0000347
348CodeGenerator::InlineRuntimeLUT* CodeGenerator::FindInlineRuntimeLUT(
349 Handle<String> name) {
350 const int entries_count =
351 sizeof(kInlineRuntimeLUT) / sizeof(InlineRuntimeLUT);
352 for (int i = 0; i < entries_count; i++) {
353 InlineRuntimeLUT* entry = &kInlineRuntimeLUT[i];
354 if (name->IsEqualTo(CStrVector(entry->name))) {
355 return entry;
356 }
357 }
358 return NULL;
359}
360
361
362bool CodeGenerator::CheckForInlineRuntimeCall(CallRuntime* node) {
363 ZoneList<Expression*>* args = node->arguments();
364 Handle<String> name = node->name();
365 if (name->length() > 0 && name->Get(0) == '_') {
366 InlineRuntimeLUT* entry = FindInlineRuntimeLUT(name);
367 if (entry != NULL) {
368 ((*this).*(entry->method))(args);
369 return true;
370 }
371 }
372 return false;
373}
374
375
376bool CodeGenerator::PatchInlineRuntimeEntry(Handle<String> name,
377 const CodeGenerator::InlineRuntimeLUT& new_entry,
378 CodeGenerator::InlineRuntimeLUT* old_entry) {
379 InlineRuntimeLUT* entry = FindInlineRuntimeLUT(name);
380 if (entry == NULL) return false;
381 if (old_entry != NULL) {
382 old_entry->name = entry->name;
383 old_entry->method = entry->method;
384 }
385 entry->name = new_entry.name;
386 entry->method = new_entry.method;
387 return true;
388}
389
390
Steve Block6ded16b2010-05-10 14:33:55 +0100391int CodeGenerator::InlineRuntimeCallArgumentsCount(Handle<String> name) {
392 CodeGenerator::InlineRuntimeLUT* f =
393 CodeGenerator::FindInlineRuntimeLUT(name);
394 if (f != NULL) return f->nargs;
395 return -1;
396}
397
398
Steve Block3ce2e202009-11-05 08:53:23 +0000399// Simple condition analysis. ALWAYS_TRUE and ALWAYS_FALSE represent a
400// known result for the test expression, with no side effects.
401CodeGenerator::ConditionAnalysis CodeGenerator::AnalyzeCondition(
402 Expression* cond) {
403 if (cond == NULL) return ALWAYS_TRUE;
404
405 Literal* lit = cond->AsLiteral();
406 if (lit == NULL) return DONT_KNOW;
407
408 if (lit->IsTrue()) {
409 return ALWAYS_TRUE;
410 } else if (lit->IsFalse()) {
411 return ALWAYS_FALSE;
412 }
413
414 return DONT_KNOW;
415}
416
417
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100418bool CodeGenerator::RecordPositions(MacroAssembler* masm,
419 int pos,
420 bool right_here) {
Steve Blocka7e24c12009-10-30 11:49:00 +0000421 if (pos != RelocInfo::kNoPosition) {
Steve Block3ce2e202009-11-05 08:53:23 +0000422 masm->RecordStatementPosition(pos);
423 masm->RecordPosition(pos);
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100424 if (right_here) {
425 return masm->WriteRecordedPositions();
426 }
Steve Blocka7e24c12009-10-30 11:49:00 +0000427 }
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100428 return false;
Steve Blocka7e24c12009-10-30 11:49:00 +0000429}
430
431
432void CodeGenerator::CodeForFunctionPosition(FunctionLiteral* fun) {
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100433 if (FLAG_debug_info) RecordPositions(masm(), fun->start_position(), false);
Steve Blocka7e24c12009-10-30 11:49:00 +0000434}
435
436
437void CodeGenerator::CodeForReturnPosition(FunctionLiteral* fun) {
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100438 if (FLAG_debug_info) RecordPositions(masm(), fun->end_position(), false);
Steve Blocka7e24c12009-10-30 11:49:00 +0000439}
440
441
442void CodeGenerator::CodeForStatementPosition(Statement* stmt) {
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100443 if (FLAG_debug_info) RecordPositions(masm(), stmt->statement_pos(), false);
Steve Blocka7e24c12009-10-30 11:49:00 +0000444}
445
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100446
Steve Blockd0582a62009-12-15 09:54:21 +0000447void CodeGenerator::CodeForDoWhileConditionPosition(DoWhileStatement* stmt) {
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100448 if (FLAG_debug_info)
449 RecordPositions(masm(), stmt->condition_position(), false);
Steve Blockd0582a62009-12-15 09:54:21 +0000450}
Steve Blocka7e24c12009-10-30 11:49:00 +0000451
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100452
Steve Blocka7e24c12009-10-30 11:49:00 +0000453void CodeGenerator::CodeForSourcePosition(int pos) {
454 if (FLAG_debug_info && pos != RelocInfo::kNoPosition) {
455 masm()->RecordPosition(pos);
456 }
457}
458
459
Leon Clarkee46be812010-01-19 14:06:41 +0000460const char* GenericUnaryOpStub::GetName() {
461 switch (op_) {
462 case Token::SUB:
Leon Clarkeac952652010-07-15 11:15:24 +0100463 if (negative_zero_ == kStrictNegativeZero) {
464 return overwrite_ == UNARY_OVERWRITE
465 ? "GenericUnaryOpStub_SUB_Overwrite_Strict0"
466 : "GenericUnaryOpStub_SUB_Alloc_Strict0";
467 } else {
468 return overwrite_ == UNARY_OVERWRITE
469 ? "GenericUnaryOpStub_SUB_Overwrite_Ignore0"
470 : "GenericUnaryOpStub_SUB_Alloc_Ignore0";
471 }
Leon Clarkee46be812010-01-19 14:06:41 +0000472 case Token::BIT_NOT:
Leon Clarkeac952652010-07-15 11:15:24 +0100473 return overwrite_ == UNARY_OVERWRITE
Leon Clarkee46be812010-01-19 14:06:41 +0000474 ? "GenericUnaryOpStub_BIT_NOT_Overwrite"
475 : "GenericUnaryOpStub_BIT_NOT_Alloc";
476 default:
477 UNREACHABLE();
478 return "<unknown>";
479 }
480}
481
482
Steve Blocka7e24c12009-10-30 11:49:00 +0000483void ArgumentsAccessStub::Generate(MacroAssembler* masm) {
484 switch (type_) {
Steve Blocka7e24c12009-10-30 11:49:00 +0000485 case READ_ELEMENT: GenerateReadElement(masm); break;
486 case NEW_OBJECT: GenerateNewObject(masm); break;
487 }
488}
489
490
Leon Clarke4515c472010-02-03 11:58:03 +0000491int CEntryStub::MinorKey() {
492 ASSERT(result_size_ <= 2);
493#ifdef _WIN64
494 return ExitFrameModeBits::encode(mode_)
495 | IndirectResultBits::encode(result_size_ > 1);
496#else
497 return ExitFrameModeBits::encode(mode_);
498#endif
499}
500
501
Steve Blockd0582a62009-12-15 09:54:21 +0000502bool ApiGetterEntryStub::GetCustomCache(Code** code_out) {
503 Object* cache = info()->load_stub_cache();
504 if (cache->IsUndefined()) {
505 return false;
506 } else {
507 *code_out = Code::cast(cache);
508 return true;
509 }
510}
511
512
513void ApiGetterEntryStub::SetCustomCache(Code* value) {
514 info()->set_load_stub_cache(value);
515}
516
517
Steve Blocka7e24c12009-10-30 11:49:00 +0000518} } // namespace v8::internal