blob: bda697abafdb2cc9e6fa85c0f5c8d891476ef7e9 [file] [log] [blame]
Kristian Monsen0d5e1162010-09-30 15:31:59 +01001// Copyright 2010 the V8 project authors. All rights reserved.
Steve Blocka7e24c12009-10-30 11:49:00 +00002// 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());
Iain Merrick75681382010-08-19 15:07:18 +010080 if (code->AutoSaveAndRestore()) {
81 code->SaveRegisters();
82 }
Steve Blocka7e24c12009-10-30 11:49:00 +000083 code->Generate();
Iain Merrick75681382010-08-19 15:07:18 +010084 if (code->AutoSaveAndRestore()) {
85 code->RestoreRegisters();
86 code->Exit();
87 }
Steve Blocka7e24c12009-10-30 11:49:00 +000088 }
89}
90
91
Iain Merrick75681382010-08-19 15:07:18 +010092void DeferredCode::Exit() {
93 masm_->jmp(exit_label());
94}
95
96
Steve Blocka7e24c12009-10-30 11:49:00 +000097void CodeGenerator::SetFrame(VirtualFrame* new_frame,
98 RegisterFile* non_frame_registers) {
99 RegisterFile saved_counts;
100 if (has_valid_frame()) {
101 frame_->DetachFromCodeGenerator();
102 // The remaining register reference counts are the non-frame ones.
103 allocator_->SaveTo(&saved_counts);
104 }
105
106 if (new_frame != NULL) {
107 // Restore the non-frame register references that go with the new frame.
108 allocator_->RestoreFrom(non_frame_registers);
109 new_frame->AttachToCodeGenerator();
110 }
111
112 frame_ = new_frame;
113 saved_counts.CopyTo(non_frame_registers);
114}
115
116
117void CodeGenerator::DeleteFrame() {
118 if (has_valid_frame()) {
119 frame_->DetachFromCodeGenerator();
120 frame_ = NULL;
121 }
122}
123
124
Andrei Popescu31002712010-02-23 13:46:05 +0000125void CodeGenerator::MakeCodePrologue(CompilationInfo* info) {
Steve Blocka7e24c12009-10-30 11:49:00 +0000126#ifdef DEBUG
127 bool print_source = false;
128 bool print_ast = false;
Steve Block3ce2e202009-11-05 08:53:23 +0000129 bool print_json_ast = false;
Steve Blocka7e24c12009-10-30 11:49:00 +0000130 const char* ftype;
131
132 if (Bootstrapper::IsActive()) {
133 print_source = FLAG_print_builtin_source;
134 print_ast = FLAG_print_builtin_ast;
Steve Block3ce2e202009-11-05 08:53:23 +0000135 print_json_ast = FLAG_print_builtin_json_ast;
Steve Blocka7e24c12009-10-30 11:49:00 +0000136 ftype = "builtin";
137 } else {
138 print_source = FLAG_print_source;
139 print_ast = FLAG_print_ast;
Steve Block3ce2e202009-11-05 08:53:23 +0000140 print_json_ast = FLAG_print_json_ast;
Steve Blocka7e24c12009-10-30 11:49:00 +0000141 ftype = "user-defined";
142 }
143
144 if (FLAG_trace_codegen || print_source || print_ast) {
145 PrintF("*** Generate code for %s function: ", ftype);
Andrei Popescu31002712010-02-23 13:46:05 +0000146 info->function()->name()->ShortPrint();
Steve Blocka7e24c12009-10-30 11:49:00 +0000147 PrintF(" ***\n");
148 }
149
150 if (print_source) {
Andrei Popescu31002712010-02-23 13:46:05 +0000151 PrintF("--- Source from AST ---\n%s\n",
152 PrettyPrinter().PrintProgram(info->function()));
Steve Blocka7e24c12009-10-30 11:49:00 +0000153 }
154
155 if (print_ast) {
Andrei Popescu31002712010-02-23 13:46:05 +0000156 PrintF("--- AST ---\n%s\n",
157 AstPrinter().PrintProgram(info->function()));
Steve Block3ce2e202009-11-05 08:53:23 +0000158 }
159
160 if (print_json_ast) {
161 JsonAstBuilder builder;
Andrei Popescu31002712010-02-23 13:46:05 +0000162 PrintF("%s", builder.BuildProgram(info->function()));
Steve Blocka7e24c12009-10-30 11:49:00 +0000163 }
164#endif // DEBUG
Steve Block3ce2e202009-11-05 08:53:23 +0000165}
Steve Blocka7e24c12009-10-30 11:49:00 +0000166
Steve Blocka7e24c12009-10-30 11:49:00 +0000167
Andrei Popescu31002712010-02-23 13:46:05 +0000168Handle<Code> CodeGenerator::MakeCodeEpilogue(MacroAssembler* masm,
Steve Block3ce2e202009-11-05 08:53:23 +0000169 Code::Flags flags,
Andrei Popescu31002712010-02-23 13:46:05 +0000170 CompilationInfo* info) {
Steve Block3ce2e202009-11-05 08:53:23 +0000171 // Allocate and install the code.
Steve Blocka7e24c12009-10-30 11:49:00 +0000172 CodeDesc desc;
Steve Block3ce2e202009-11-05 08:53:23 +0000173 masm->GetCode(&desc);
Ben Murdoch3bec4d22010-07-22 14:51:16 +0100174 Handle<Code> code = Factory::NewCode(desc, flags, masm->CodeObject());
Steve Blocka7e24c12009-10-30 11:49:00 +0000175
Steve Blocka7e24c12009-10-30 11:49:00 +0000176#ifdef ENABLE_DISASSEMBLER
Steve Block3ce2e202009-11-05 08:53:23 +0000177 bool print_code = Bootstrapper::IsActive()
178 ? FLAG_print_builtin_code
179 : FLAG_print_code;
Steve Blocka7e24c12009-10-30 11:49:00 +0000180 if (print_code) {
181 // Print the source code if available.
Andrei Popescu31002712010-02-23 13:46:05 +0000182 Handle<Script> script = info->script();
183 FunctionLiteral* function = info->function();
Steve Blocka7e24c12009-10-30 11:49:00 +0000184 if (!script->IsUndefined() && !script->source()->IsUndefined()) {
185 PrintF("--- Raw source ---\n");
186 StringInputBuffer stream(String::cast(script->source()));
Andrei Popescu31002712010-02-23 13:46:05 +0000187 stream.Seek(function->start_position());
Steve Block3ce2e202009-11-05 08:53:23 +0000188 // fun->end_position() points to the last character in the stream. We
Steve Blocka7e24c12009-10-30 11:49:00 +0000189 // need to compensate by adding one to calculate the length.
Andrei Popescu31002712010-02-23 13:46:05 +0000190 int source_len =
191 function->end_position() - function->start_position() + 1;
Steve Blocka7e24c12009-10-30 11:49:00 +0000192 for (int i = 0; i < source_len; i++) {
193 if (stream.has_more()) PrintF("%c", stream.GetNext());
194 }
195 PrintF("\n\n");
196 }
197 PrintF("--- Code ---\n");
Andrei Popescu31002712010-02-23 13:46:05 +0000198 code->Disassemble(*function->name()->ToCString());
Steve Blocka7e24c12009-10-30 11:49:00 +0000199 }
200#endif // ENABLE_DISASSEMBLER
201
202 if (!code.is_null()) {
203 Counters::total_compiled_code_size.Increment(code->instruction_size());
204 }
Steve Blocka7e24c12009-10-30 11:49:00 +0000205 return code;
206}
207
208
Ben Murdochf87a2032010-10-22 12:50:53 +0100209// Generate the code. Compile the AST and assemble all the pieces into a
210// Code object.
211bool CodeGenerator::MakeCode(CompilationInfo* info) {
Andrei Popescu31002712010-02-23 13:46:05 +0000212 Handle<Script> script = info->script();
Leon Clarked91b9f72010-01-27 17:25:45 +0000213 if (!script->IsUndefined() && !script->source()->IsUndefined()) {
214 int len = String::cast(script->source())->length();
215 Counters::total_old_codegen_source_size.Increment(len);
216 }
Andrei Popescu31002712010-02-23 13:46:05 +0000217 MakeCodePrologue(info);
Steve Block3ce2e202009-11-05 08:53:23 +0000218 // Generate code.
219 const int kInitialBufferSize = 4 * KB;
Leon Clarke4515c472010-02-03 11:58:03 +0000220 MacroAssembler masm(NULL, kInitialBufferSize);
Andrei Popescu31002712010-02-23 13:46:05 +0000221 CodeGenerator cgen(&masm);
Steve Block3ce2e202009-11-05 08:53:23 +0000222 CodeGeneratorScope scope(&cgen);
Andrei Popescu402d9372010-02-26 13:31:12 +0000223 cgen.Generate(info);
Steve Block3ce2e202009-11-05 08:53:23 +0000224 if (cgen.HasStackOverflow()) {
225 ASSERT(!Top::has_pending_exception());
Ben Murdochf87a2032010-10-22 12:50:53 +0100226 return false;
Steve Block3ce2e202009-11-05 08:53:23 +0000227 }
228
Ben Murdochf87a2032010-10-22 12:50:53 +0100229 InLoopFlag in_loop = info->is_in_loop() ? IN_LOOP : NOT_IN_LOOP;
Steve Block3ce2e202009-11-05 08:53:23 +0000230 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION, in_loop);
Ben Murdochf87a2032010-10-22 12:50:53 +0100231 Handle<Code> code = MakeCodeEpilogue(cgen.masm(), flags, info);
232 info->SetCode(code); // May be an empty handle.
233 return !code.is_null();
Steve Block3ce2e202009-11-05 08:53:23 +0000234}
235
236
Steve Blocka7e24c12009-10-30 11:49:00 +0000237#ifdef ENABLE_LOGGING_AND_PROFILING
238
239bool CodeGenerator::ShouldGenerateLog(Expression* type) {
240 ASSERT(type != NULL);
Steve Block6ded16b2010-05-10 14:33:55 +0100241 if (!Logger::is_logging() && !CpuProfiler::is_profiling()) return false;
Steve Blocka7e24c12009-10-30 11:49:00 +0000242 Handle<String> name = Handle<String>::cast(type->AsLiteral()->handle());
243 if (FLAG_log_regexp) {
244 static Vector<const char> kRegexp = CStrVector("regexp");
245 if (name->IsEqualTo(kRegexp))
246 return true;
247 }
248 return false;
249}
250
251#endif
252
253
Steve Blocka7e24c12009-10-30 11:49:00 +0000254Handle<Code> CodeGenerator::ComputeCallInitialize(
255 int argc,
256 InLoopFlag in_loop) {
257 if (in_loop == IN_LOOP) {
258 // Force the creation of the corresponding stub outside loops,
259 // because it may be used when clearing the ICs later - it is
260 // possible for a series of IC transitions to lose the in-loop
261 // information, and the IC clearing code can't generate a stub
262 // that it needs so we need to ensure it is generated already.
263 ComputeCallInitialize(argc, NOT_IN_LOOP);
264 }
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100265 CALL_HEAP_FUNCTION(
266 StubCache::ComputeCallInitialize(argc, in_loop, Code::CALL_IC),
267 Code);
Steve Blocka7e24c12009-10-30 11:49:00 +0000268}
269
270
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100271Handle<Code> CodeGenerator::ComputeKeyedCallInitialize(
272 int argc,
273 InLoopFlag in_loop) {
274 if (in_loop == IN_LOOP) {
275 // Force the creation of the corresponding stub outside loops,
276 // because it may be used when clearing the ICs later - it is
277 // possible for a series of IC transitions to lose the in-loop
278 // information, and the IC clearing code can't generate a stub
279 // that it needs so we need to ensure it is generated already.
280 ComputeKeyedCallInitialize(argc, NOT_IN_LOOP);
281 }
282 CALL_HEAP_FUNCTION(
283 StubCache::ComputeCallInitialize(argc, in_loop, Code::KEYED_CALL_IC),
284 Code);
285}
286
Steve Blocka7e24c12009-10-30 11:49:00 +0000287void CodeGenerator::ProcessDeclarations(ZoneList<Declaration*>* declarations) {
288 int length = declarations->length();
289 int globals = 0;
290 for (int i = 0; i < length; i++) {
291 Declaration* node = declarations->at(i);
292 Variable* var = node->proxy()->var();
Kristian Monsen0d5e1162010-09-30 15:31:59 +0100293 Slot* slot = var->AsSlot();
Steve Blocka7e24c12009-10-30 11:49:00 +0000294
295 // If it was not possible to allocate the variable at compile
296 // time, we need to "declare" it at runtime to make sure it
297 // actually exists in the local context.
298 if ((slot != NULL && slot->type() == Slot::LOOKUP) || !var->is_global()) {
299 VisitDeclaration(node);
300 } else {
301 // Count global variables and functions for later processing
302 globals++;
303 }
304 }
305
306 // Return in case of no declared global functions or variables.
307 if (globals == 0) return;
308
309 // Compute array of global variable and function declarations.
310 Handle<FixedArray> array = Factory::NewFixedArray(2 * globals, TENURED);
311 for (int j = 0, i = 0; i < length; i++) {
312 Declaration* node = declarations->at(i);
313 Variable* var = node->proxy()->var();
Kristian Monsen0d5e1162010-09-30 15:31:59 +0100314 Slot* slot = var->AsSlot();
Steve Blocka7e24c12009-10-30 11:49:00 +0000315
316 if ((slot != NULL && slot->type() == Slot::LOOKUP) || !var->is_global()) {
317 // Skip - already processed.
318 } else {
319 array->set(j++, *(var->name()));
320 if (node->fun() == NULL) {
321 if (var->mode() == Variable::CONST) {
322 // In case this is const property use the hole.
323 array->set_the_hole(j++);
324 } else {
325 array->set_undefined(j++);
326 }
327 } else {
Steve Block6ded16b2010-05-10 14:33:55 +0100328 Handle<SharedFunctionInfo> function =
Ben Murdochf87a2032010-10-22 12:50:53 +0100329 Compiler::BuildFunctionInfo(node->fun(), script());
Steve Blocka7e24c12009-10-30 11:49:00 +0000330 // Check for stack-overflow exception.
Ben Murdochf87a2032010-10-22 12:50:53 +0100331 if (function.is_null()) {
332 SetStackOverflow();
333 return;
334 }
Steve Blocka7e24c12009-10-30 11:49:00 +0000335 array->set(j++, *function);
336 }
337 }
338 }
339
340 // Invoke the platform-dependent code generator to do the actual
341 // declaration the global variables and functions.
342 DeclareGlobals(array);
343}
344
345
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100346void CodeGenerator::VisitIncrementOperation(IncrementOperation* expr) {
347 UNREACHABLE();
348}
349
350
Kristian Monsen0d5e1162010-09-30 15:31:59 +0100351// Lookup table for code generators for special runtime calls which are
352// generated inline.
353#define INLINE_FUNCTION_GENERATOR_ADDRESS(Name, argc, ressize) \
354 &CodeGenerator::Generate##Name,
Steve Blocka7e24c12009-10-30 11:49:00 +0000355
Kristian Monsen0d5e1162010-09-30 15:31:59 +0100356const CodeGenerator::InlineFunctionGenerator
357 CodeGenerator::kInlineFunctionGenerators[] = {
358 INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS)
359 INLINE_RUNTIME_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS)
Steve Blocka7e24c12009-10-30 11:49:00 +0000360};
Kristian Monsen0d5e1162010-09-30 15:31:59 +0100361#undef INLINE_FUNCTION_GENERATOR_ADDRESS
Steve Blocka7e24c12009-10-30 11:49:00 +0000362
363
Steve Blocka7e24c12009-10-30 11:49:00 +0000364bool CodeGenerator::CheckForInlineRuntimeCall(CallRuntime* node) {
365 ZoneList<Expression*>* args = node->arguments();
366 Handle<String> name = node->name();
Kristian Monsen0d5e1162010-09-30 15:31:59 +0100367 Runtime::Function* function = node->function();
368 if (function != NULL && function->intrinsic_type == Runtime::INLINE) {
Ben Murdochf87a2032010-10-22 12:50:53 +0100369 int lookup_index = static_cast<int>(function->function_id) -
370 static_cast<int>(Runtime::kFirstInlineFunction);
371 ASSERT(lookup_index >= 0);
372 ASSERT(static_cast<size_t>(lookup_index) <
373 ARRAY_SIZE(kInlineFunctionGenerators));
374 InlineFunctionGenerator generator = kInlineFunctionGenerators[lookup_index];
375 (this->*generator)(args);
376 return true;
Steve Blocka7e24c12009-10-30 11:49:00 +0000377 }
378 return false;
379}
380
381
Steve Block3ce2e202009-11-05 08:53:23 +0000382// Simple condition analysis. ALWAYS_TRUE and ALWAYS_FALSE represent a
383// known result for the test expression, with no side effects.
384CodeGenerator::ConditionAnalysis CodeGenerator::AnalyzeCondition(
385 Expression* cond) {
386 if (cond == NULL) return ALWAYS_TRUE;
387
388 Literal* lit = cond->AsLiteral();
389 if (lit == NULL) return DONT_KNOW;
390
391 if (lit->IsTrue()) {
392 return ALWAYS_TRUE;
393 } else if (lit->IsFalse()) {
394 return ALWAYS_FALSE;
395 }
396
397 return DONT_KNOW;
398}
399
400
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100401bool CodeGenerator::RecordPositions(MacroAssembler* masm,
402 int pos,
403 bool right_here) {
Steve Blocka7e24c12009-10-30 11:49:00 +0000404 if (pos != RelocInfo::kNoPosition) {
Steve Block3ce2e202009-11-05 08:53:23 +0000405 masm->RecordStatementPosition(pos);
406 masm->RecordPosition(pos);
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100407 if (right_here) {
408 return masm->WriteRecordedPositions();
409 }
Steve Blocka7e24c12009-10-30 11:49:00 +0000410 }
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100411 return false;
Steve Blocka7e24c12009-10-30 11:49:00 +0000412}
413
414
415void CodeGenerator::CodeForFunctionPosition(FunctionLiteral* fun) {
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100416 if (FLAG_debug_info) RecordPositions(masm(), fun->start_position(), false);
Steve Blocka7e24c12009-10-30 11:49:00 +0000417}
418
419
420void CodeGenerator::CodeForReturnPosition(FunctionLiteral* fun) {
Ben Murdochbb769b22010-08-11 14:56:33 +0100421 if (FLAG_debug_info) RecordPositions(masm(), fun->end_position() - 1, false);
Steve Blocka7e24c12009-10-30 11:49:00 +0000422}
423
424
425void CodeGenerator::CodeForStatementPosition(Statement* stmt) {
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100426 if (FLAG_debug_info) RecordPositions(masm(), stmt->statement_pos(), false);
Steve Blocka7e24c12009-10-30 11:49:00 +0000427}
428
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100429
Steve Blockd0582a62009-12-15 09:54:21 +0000430void CodeGenerator::CodeForDoWhileConditionPosition(DoWhileStatement* stmt) {
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100431 if (FLAG_debug_info)
432 RecordPositions(masm(), stmt->condition_position(), false);
Steve Blockd0582a62009-12-15 09:54:21 +0000433}
Steve Blocka7e24c12009-10-30 11:49:00 +0000434
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100435
Steve Blocka7e24c12009-10-30 11:49:00 +0000436void CodeGenerator::CodeForSourcePosition(int pos) {
437 if (FLAG_debug_info && pos != RelocInfo::kNoPosition) {
438 masm()->RecordPosition(pos);
439 }
440}
441
442
Leon Clarkee46be812010-01-19 14:06:41 +0000443const char* GenericUnaryOpStub::GetName() {
444 switch (op_) {
445 case Token::SUB:
Leon Clarkeac952652010-07-15 11:15:24 +0100446 if (negative_zero_ == kStrictNegativeZero) {
447 return overwrite_ == UNARY_OVERWRITE
448 ? "GenericUnaryOpStub_SUB_Overwrite_Strict0"
449 : "GenericUnaryOpStub_SUB_Alloc_Strict0";
450 } else {
451 return overwrite_ == UNARY_OVERWRITE
452 ? "GenericUnaryOpStub_SUB_Overwrite_Ignore0"
453 : "GenericUnaryOpStub_SUB_Alloc_Ignore0";
454 }
Leon Clarkee46be812010-01-19 14:06:41 +0000455 case Token::BIT_NOT:
Leon Clarkeac952652010-07-15 11:15:24 +0100456 return overwrite_ == UNARY_OVERWRITE
Leon Clarkee46be812010-01-19 14:06:41 +0000457 ? "GenericUnaryOpStub_BIT_NOT_Overwrite"
458 : "GenericUnaryOpStub_BIT_NOT_Alloc";
459 default:
460 UNREACHABLE();
461 return "<unknown>";
462 }
463}
464
465
Steve Blocka7e24c12009-10-30 11:49:00 +0000466void ArgumentsAccessStub::Generate(MacroAssembler* masm) {
467 switch (type_) {
Steve Blocka7e24c12009-10-30 11:49:00 +0000468 case READ_ELEMENT: GenerateReadElement(masm); break;
469 case NEW_OBJECT: GenerateNewObject(masm); break;
470 }
471}
472
473
Leon Clarke4515c472010-02-03 11:58:03 +0000474int CEntryStub::MinorKey() {
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100475 ASSERT(result_size_ == 1 || result_size_ == 2);
Leon Clarke4515c472010-02-03 11:58:03 +0000476#ifdef _WIN64
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100477 return result_size_ == 1 ? 0 : 1;
Leon Clarke4515c472010-02-03 11:58:03 +0000478#else
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100479 return 0;
Leon Clarke4515c472010-02-03 11:58:03 +0000480#endif
481}
482
483
Steve Blockd0582a62009-12-15 09:54:21 +0000484bool ApiGetterEntryStub::GetCustomCache(Code** code_out) {
485 Object* cache = info()->load_stub_cache();
486 if (cache->IsUndefined()) {
487 return false;
488 } else {
489 *code_out = Code::cast(cache);
490 return true;
491 }
492}
493
494
495void ApiGetterEntryStub::SetCustomCache(Code* value) {
496 info()->set_load_stub_cache(value);
497}
498
499
Steve Blocka7e24c12009-10-30 11:49:00 +0000500} } // namespace v8::internal